<commit_before><?php
/**
 * Nooku Framework - http://www.nooku.org
 *
 * @copyright	Copyright (C) 2011 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		git://git.assembla.com/nooku-framework.git for the canonical source repository
 */

use Nooku\Library;

/**
 * Http Dispatcher
 *
 * @author  <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @package Component\Files
 */
class FilesDispatcherHttp extends Library\DispatcherHttp
{
    public function __construct(Library\ObjectConfig $config)
    {
        parent::__construct($config);

        // Return JSON response when possible
        $this->registerCallback('after.post' , array($this, 'renderResponse'));

        // Return correct status code for plupload
        $this->getObject('application')->registerCallback('before.send', array($this, 'setStatusForPlupload'));
    }

    public function renderResponse(Library\DispatcherContext $context)
    {
        if ($context->action !== 'delete' && $this->getRequest()->getFormat() === 'json') {
            $this->getController()->execute('render', $context);
        }
    }

    /**
     * We need to return 200 even if an error happens in requests using Plupload.
     * Otherwise we cannot get the error message and display it to the user interface
     */
    public function setStatusForPlupload(Library\DispatcherContext $context)
    {
        if ($context->request->getFormat() == 'json' && $context->request->query->get('plupload', 'int')) {
            $context->response->setStatus('200');
        }
    }
}<commit_msg>Use DispatcherContextInterface instead of DispatcherContext<commit_after><?php
/**
 * Nooku Framework - http://www.nooku.org
 *
 * @copyright	Copyright (C) 2011 - 2013 <NAME> and Timble CVBA. (http://www.timble.net)
 * @license		GNU GPLv3 <http://www.gnu.org/licenses/gpl.html>
 * @link		git://git.assembla.com/nooku-framework.git for the canonical source repository
 */

use Nooku\Library;

/**
 * Http Dispatcher
 *
 * @author  <NAME> <http://nooku.assembla.com/profile/ercanozkaya>
 * @package Component\Files
 */
class FilesDispatcherHttp extends Library\DispatcherHttp
{
    public function __construct(Library\ObjectConfig $config)
    {
        parent::__construct($config);

        // Return JSON response when possible
        $this->registerCallback('after.post' , array($this, 'renderResponse'));

        // Return correct status code for plupload
        $this->getObject('application')->registerCallback('before.send', array($this, 'setStatusForPlupload'));
    }

    public function renderResponse(Library\DispatcherContextInterface $context)
    {
        if ($context->action !== 'delete' && $this->getRequest()->getFormat() === 'json') {
            $this->getController()->execute('render', $context);
        }
    }

    /**
     * We need to return 200 even if an error happens in requests using Plupload.
     * Otherwise we cannot get the error message and display it to the user interface
     */
    public function setStatusForPlupload(Library\DispatcherContextInterface $context)
    {
        if ($context->request->getFormat() == 'json' && $context->request->query->get('plupload', 'int')) {
            $context->response->setStatus('200');
        }
    }
}
{'fraction_non_alphanumeric': 0.14466546112115733, 'fraction_numerical': 0.009041591320072333, 'mean_word_length': 3.304798962386511, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 41, 'https://': 0, 'lorem ipsum': 0, 'www.': 6, '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': '1456315', 'n_tokens_mistral': 980, 'n_tokens_neox': 930, 'n_words': 224}