<commit_before><?php
/*
 * douggr/zf-rest
 *
 * @link https://github.com/douggr/zf-rest for the canonical source repository
 * @version 1.1.4
 *
 * For the full copyright and license information, please view the LICENSE
 * file distributed with this source code.
 */

/**
 * {@inheritdoc}
 *
 * All API requests MUST include a valid User-Agent header. Requests with no
 * User-Agent header will be rejected.
 */
class ZfRest_Controller_Rest extends Zend_Rest_Controller
{
    use ZfRest_Controller_Auth;

    /**
     * Request data
     */
    protected $input;

    /**
     * Response data
     */
    protected $data;

    /**
     * {@inheritdoc}
     */
    private $_errors = [];

    /**
     * @var integer
     */
    private static $_forwardStack = 0;

    /**
     * @var integer
     */
    private static $_parents = -1;

    /**
     * Used for deleting resources.
     */
    public function deleteAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * Used for retrieving resources.
     */
    public function getAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * Issued against any resource to get just the HTTP header info.
     */
    final public function headAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(204);
    }

    /**
     * Used for retrieving resources.
     */
    public function indexAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * {@inheritdoc}
     */
    final public function init()
    {
        $this
            ->getResponse()
            // {{{ BEGIN CORS
            ->setHeader('Access-Control-Allow-Origin', '*', true)
            ->setHeader('Access-Control-Allow-Credentials', 'true', true)
            ->setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE', true)
            ->setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Preferred-Locale, X-Context, Authorization', true)
            ->setHeader('Access-Control-Max-Age', '1728000', true)
            // END CORS }}}

            ->setHeader('X-Preferred-Locale', $this->getPreferredLocale(), true)
            ->setHeader('X-Context', $this->getContext(), true)
            ->setHeader('Vary', 'Accept-Encoding', true)
            ->setHeader('Content-Type', 'application/json; charset=utf-8', true);

        $this->setAuth($this->getRequest()->getHeader('Authorization'))
            ->setContext($this->getContext());

        ZfRest_Db_Table::setAuthUser($this->getCurrentUser());
        ZfRest_Db_Table::setContext($this->getContext());
        ZfRest_Db_Table::setPreferredLocale($this->getPreferredLocale());
<commit_msg> Not sure why these methods could not be extended.<commit_after><?php
/*
 * douggr/zf-rest
 *
 * @link https://github.com/douggr/zf-rest for the canonical source repository
 * @version 1.1.4
 *
 * For the full copyright and license information, please view the LICENSE
 * file distributed with this source code.
 */

/**
 * {@inheritdoc}
 *
 * All API requests MUST include a valid User-Agent header. Requests with no
 * User-Agent header will be rejected.
 */
class ZfRest_Controller_Rest extends Zend_Rest_Controller
{
    use ZfRest_Controller_Auth;

    /**
     * Request data
     */
    protected $input;

    /**
     * Response data
     */
    protected $data;

    /**
     * {@inheritdoc}
     */
    private $_errors = [];

    /**
     * @var integer
     */
    private static $_forwardStack = 0;

    /**
     * @var integer
     */
    private static $_parents = -1;

    /**
     * Used for deleting resources.
     */
    public function deleteAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * Used for retrieving resources.
     */
    public function getAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * Issued against any resource to get just the HTTP header info.
     */
    final public function headAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(204);
    }

    /**
     * Used for retrieving resources.
     */
    public function indexAction()
    {
        $this->getResponse()
            ->setHttpResponseCode(405);
    }

    /**
     * {@inheritdoc}
     * Note: Remember to call parent::init() if you override this one.
     */
    public function init()
    {
        $this
            ->getResponse()
            // {{{ BEGIN CORS
            ->setHeader('Access-Control-Allow-Origin', '*', true)
            ->setHeader('Access-Control-Allow-Credentials', 'true', true)
            ->setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE', true)
            ->setHeader('Access-Control-Allow-Headers', 'Content-Type, X-Preferred-Locale, X-Context, Authorization', true)
            ->setHeader('Access-Control-Max-Age', '1728000', true)
            // END CORS }}}

            ->setHeader('X-Preferred-Locale', $this->getPreferredLocale(), true)
            ->setHeader('X-Context', $this->getContext(), true)
            ->setHeader('Vary', 'Accept-Encoding', true)
            ->setHeader('Content-Type', 'application/json; charset=utf-8', true);

        $this->setAuth($this->getRequest()->getHeader('Authorization'))
            ->setContext($this->getContext());

        ZfRest_Db_Table::setAuthUser($this->getCurrentUser());
        ZfRest_Db_Table::setContext($this->getContext());
        ZfRest_Db_Table::setPreferredLocale($this->getPreferredLocale());

{'fraction_non_alphanumeric': 0.14341359773371104, 'fraction_numerical': 0.008852691218130312, 'mean_word_length': 2.2372492836676217, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 59, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4534610', 'n_tokens_mistral': 1662, 'n_tokens_neox': 1599, 'n_words': 358}