<commit_before><?php
/**
 * Convenience AppController that allows a controller to
 * automatically serve up a JSON version of the response
 * when it is requested via an Ajax call, such as in jQuery's
 * jQuery.ajax() method
 *
 * @package default
 */
abstract class AjaxController extends Controller {

/**
 * Override for the current HTTP-Status code
 *
 * For use when Controller::redirect() is not called and
 * the status code is the result of some request error
 *
 * @var string
 * @access protected
 */
	protected $_status = null;

/**
 * Special JSON-response short-circuit variable
 *
 * @var string
 * @access protected
 */
	protected $_disableAjax = false;

/**
 * Object constructor - Adds the RequestHandler and Session
 * components if necessary
 *
 * @return void
 */
	public function __construct() {
		if (!in_array('RequestHandler', $this->components)) {
			$this->components[] = 'RequestHandler';
		}

		if (!in_array('Session', $this->components)) {
			$this->components[] = 'Session';
		}

		parent::__construct();
	}

/**
 * Convenience method to short-circuit Ajax access to methods
 * and force a regular response from the controller
 *
 * @return void
 */
	protected function _disableAjax() {
		$args = func_get_args();
		if (is_array($args[0])) {
			$args = $args[0];
		}

		foreach ($args as $arg) {
			if ($arg == $this->action) {
				$this->_disableAjax = true;
				break;
			}
		}
	}

/**
 * Override the redirect method to call $this->_respond() in case
 * the response should be json
 *
 * Will terminate if the response should be json
 *
 * @param mixed $url A string or array-based URL pointing to another location within the app,
 *     or an absolute URL
 * @param integer $status Optional HTTP status code (eg: 404)
 * @param boolean $exit If true, exit() will be called after the redirect
 * @return mixed void if $exit = false. Terminates script if $exit = true
 * @access public
 */
	public function redirect($url, $status = null, $exit = true) {
		$this->_respond(array(
			'redirect' => $url,
			'status' => $status,
		));

		parent::redirect($url, $status, $exit);
	}

/**
 * Called after the controller action is run to set the response to
 * json if necessary
 *
 * @access public
 * @link http://book.cakephp.org/view/984/Callbacks
 */
	public function beforeRender() {
		$this->_respond();
		return parent::beforeRender();<commit_msg>Remove @access<commit_after><?php
/**
 * Convenience AppController that allows a controller to
 * automatically serve up a JSON version of the response
 * when it is requested via an Ajax call, such as in jQuery's
 * jQuery.ajax() method
 *
 * @package default
 */
abstract class AjaxController extends Controller {

/**
 * Override for the current HTTP-Status code
 *
 * For use when Controller::redirect() is not called and
 * the status code is the result of some request error
 *
 * @var string
 * @access protected
 */
	protected $_status = null;

/**
 * Special JSON-response short-circuit variable
 *
 * @var string
 * @access protected
 */
	protected $_disableAjax = false;

/**
 * Object constructor - Adds the RequestHandler and Session
 * components if necessary
 *
 * @return void
 */
	public function __construct() {
		if (!in_array('RequestHandler', $this->components)) {
			$this->components[] = 'RequestHandler';
		}

		if (!in_array('Session', $this->components)) {
			$this->components[] = 'Session';
		}

		parent::__construct();
	}

/**
 * Convenience method to short-circuit Ajax access to methods
 * and force a regular response from the controller
 *
 * @return void
 */
	protected function _disableAjax() {
		$args = func_get_args();
		if (is_array($args[0])) {
			$args = $args[0];
		}

		foreach ($args as $arg) {
			if ($arg == $this->action) {
				$this->_disableAjax = true;
				break;
			}
		}
	}

/**
 * Override the redirect method to call $this->_respond() in case
 * the response should be json
 *
 * Will terminate if the response should be json
 *
 * @param mixed $url A string or array-based URL pointing to another location within the app,
 *     or an absolute URL
 * @param integer $status Optional HTTP status code (eg: 404)
 * @param boolean $exit If true, exit() will be called after the redirect
 * @return mixed void if $exit = false. Terminates script if $exit = true
 */
	public function redirect($url, $status = null, $exit = true) {
		$this->_respond(array(
			'redirect' => $url,
			'status' => $status,
		));

		parent::redirect($url, $status, $exit);
	}

/**
 * Called after the controller action is run to set the response to
 * json if necessary
 *
 * @link http://book.cakephp.org/view/984/Callbacks
 */
	public function beforeRender() {
		$this->_respond();
		return parent::beforeRender();
{'fraction_non_alphanumeric': 0.12587264649883648, 'fraction_numerical': 0.0033848106621535857, 'mean_word_length': 3.6262230919765166, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, 'https://': 0, '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': '1421087', 'n_tokens_mistral': 1461, 'n_tokens_neox': 1360, 'n_words': 512}