<commit_before><?php

namespace Foowie\Cron\Application\UI;

use Nette\Application;
use Nette\Application\UI\Presenter;

/**
 * @author <NAME> <<EMAIL>>
 */
class CronPresenter extends Presenter {

	/**
	 * @var \Foowie\Cron\Application\UI\SecurityToken @inject
	 */
	public $securityToken;

	/**
	 * @var \Foowie\Cron\ICron @inject
	 */
	public $cron;

	public function checkRequirements($element) {
		if ($this->securityToken !== null && $element instanceof Application\UI\PresenterComponentReflection) {
			if ($this->getParameter('token') != $this->securityToken->getSecurityToken()) {
				throw new Application\ForbiddenRequestException('Security token does not match!');
			}
		}
		parent::checkRequirements($element);
	}

	public function actionDefault() {
		$this->cron->run();
		$this->sendResponse(new Application\Responses\TextResponse(''));
	}<commit_msg>Added max_execution_time option to CronPresenter<commit_after><?php

namespace Foowie\Cron\Application\UI;

use Foowie\Cron\ICron;
use Nette\Application;
use Nette\Application\UI\Presenter;

/**
 * @author <NAME> <<EMAIL>>
 */
class CronPresenter extends Presenter {

	/**
	 * @var SecurityToken
	 */
	protected $securityToken;

	/**
	 * @var ICron
	 */
	protected $cron;

	/**
	 * @var null|int
	 */
	protected $maxExecutionTime = null;

	function __construct(ICron $cron, SecurityToken $securityToken) {
		parent::__construct();
		$this->cron = $cron;
		$this->securityToken = $securityToken;
	}

	/**
	 * @param int|null $maxExecutionTime
	 */
	public function setMaxExecutionTime($maxExecutionTime) {
		$this->maxExecutionTime = $maxExecutionTime;
	}

	public function checkRequirements($element) {
		if ($this->securityToken !== null && $element instanceof Application\UI\PresenterComponentReflection) {
			if ($this->getParameter('token') != $this->securityToken->getSecurityToken()) {
				throw new Application\ForbiddenRequestException('Security token does not match!');
			}
		}
		parent::checkRequirements($element);
	}

	public function actionDefault() {
		if($this->maxExecutionTime !== null) {
			ini_set('max_execution_time', $this->maxExecutionTime);
		}

		$this->cron->run();
		$this->sendResponse(new Application\Responses\TextResponse(''));
	}
{'fraction_non_alphanumeric': 0.15029161058770749, 'fraction_numerical': 0.0, 'mean_word_length': 4.837696335078534, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 28, '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': '2360841', 'n_tokens_mistral': 740, 'n_tokens_neox': 684, 'n_words': 131}