<commit_before><?php

/**
 * This file is part of Nepttune (https://www.peldax.com)
 *
 * Copyright (c) 2018 <NAME> (<EMAIL>)
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license. For more information, see
 * <https://www.peldax.com>.
 */

declare(strict_types = 1);

namespace App\Presenter;

final class ToolPresenter extends \Nepttune\Presenter\BaseApiPresenter implements \Nepttune\Presenter\ILink
{
    use \Nepttune\Presenter\TLink;
    use \Nepttune\Presenter\TTemplate;
    
    /** @var array */
    protected $robots;

    public function __construct(array $robots)
    {
        parent::__construct();

        $this->robots = $robots;
    }
    
    public function startup()
    {
        parent::startup();
        $this->getTemplate();
    }

    public function actionRobots()
    {
        $this->getHttpResponse()->setContentType('text/plain');

        $this->template->robots = $this->robots;
        
        $this->sendTemplate();
    }

    public function actionSitemap()
    {
        $this->getHttpResponse()->setContentType('application/xml');

        $cache = new \Nette\Caching\Cache($this->cacheStorage);

        $this->template->pages = $cache->call([$this, 'getPages']);
        $this->template->date = new \Nette\Utils\DateTime();

        $this->sendTemplate();
    }

    public function actionWorker()
    {
        $this->getHttpResponse()->addHeader('Service-Worker-Allowed', '/');
        $this->getHttpResponse()->setContentType('application/javascript');
    }

    public function getPages() : array
    {
        $pages = [];

        foreach ($this->context->findByType('\Nepttune\TI\ISitemap') as $name)
        {
            /** @var \Nepttune\TI\ISitemap $presenter */
            $presenter = $this->context->getService($name);
            $pages = array_merge($pages, $presenter->getSitemap());
        }

        return $pages;
    }
}<commit_msg>Update ToolPresenter.php<commit_after><?php

/**
 * This file is part of Nepttune (https://www.peldax.com)
 *
 * Copyright (c) 2018 <NAME> (<EMAIL>)
 *
 * This software consists of voluntary contributions made by many individuals
 * and is licensed under the MIT license. For more information, see
 * <https://www.peldax.com>.
 */

declare(strict_types = 1);

namespace App\Presenter;

final class ToolPresenter extends \Nepttune\Presenter\BaseApiPresenter implements \Nepttune\Presenter\ILink
{
    use \Nepttune\Presenter\TLink;
    use \Nepttune\Presenter\TTemplate;
    
    /** @var array */
    protected $robots;

    public function __construct(array $robots)
    {
        parent::__construct();

        $this->robots = $robots;
    }
    
    public function startup()
    {
        parent::startup();
        $this->getTemplate();
    }

    public function actionRobots()
    {
        $this->getHttpResponse()->setContentType('text/plain');

        $this->template->robots = $this->robots;
        
        $this->sendTemplate();
    }

    public function actionSitemap()
    {
        $this->getHttpResponse()->setContentType('application/xml');

        $cache = new \Nette\Caching\Cache($this->cacheStorage);

        $this->template->pages = $cache->call([$this, 'getPages']);
        $this->template->date = new \Nette\Utils\DateTime();

        $this->sendTemplate();
    }

    public function actionWorker()
    {
        $this->getHttpResponse()->addHeader('Service-Worker-Allowed', '/');
        $this->getHttpResponse()->setContentType('application/javascript');
        
        $this->sendTemplate();
    }

    public function getPages() : array
    {
        $pages = [];

        foreach ($this->context->findByType('\Nepttune\TI\ISitemap') as $name)
        {
            /** @var \Nepttune\TI\ISitemap $presenter */
            $presenter = $this->context->getService($name);
            $pages = array_merge($pages, $presenter->getSitemap());
        }

        return $pages;
    }
}
{'fraction_non_alphanumeric': 0.1507399046902433, 'fraction_numerical': 0.002508151492350138, 'mean_word_length': 2.5992779783393503, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 62, 'https://': 4, 'lorem ipsum': 0, 'www.': 4, 'xml': 2}, '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': '948695', 'n_tokens_mistral': 1222, 'n_tokens_neox': 1188, 'n_words': 224}