<commit_before><?php

namespace Bolt;

use Bolt\Debug\DebugToolbarEnabler;
use Bolt\Exception\LowlevelException;
use Bolt\Helpers\Str;
use Bolt\Provider\LoggerServiceProvider;
use Bolt\Provider\PathServiceProvider;
use Bolt\Provider\SessionServiceProvider;
use Bolt\Provider\WhoopsServiceProvider;
use Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider;
use Doctrine\DBAL\DBALException;
use RandomLib;
use SecurityLib;
use Silex;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
use Symfony\Component\Stopwatch;

class Application extends Silex\Application
{
    /**
     * The default locale, used as fallback.
     */
    const DEFAULT_LOCALE = 'en_GB';

    /**
     * @param array $values
     */
    public function __construct(array $values = [])
    {
        $values['bolt_version'] = '2.3.0';
        $values['bolt_name'] = 'alpha 1';
        $values['bolt_released'] = false; // `true` for stable releases, `false` for alpha, beta and RC.

        /** @internal Parameter to track a deprecated PHP version */
        $values['deprecated.php'] = version_compare(PHP_VERSION, '5.5.9', '<');

        parent::__construct($values);

        $this->register(new PathServiceProvider());

        // Initialize the config. Note that we do this here, on 'construct'.
        // All other initialisation is triggered from bootstrap.php
        // Warning!
        // One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
        // must be defined for working properly
        if (!isset($this['resources'])) {
            $this['resources'] = new Configuration\ResourceManager($this);
            $this['resources']->compat();
        } else {
            $this['classloader'] = $this['resources']->getClassLoader();
        }

        $this['resources']->setApp($this);
        $this->initConfig();
        $this->initLogger();
        $this['resources']->initialize();

        $this['debug'] = $this['config']->get('general/debug', false);

        // Initialize the 'editlink' and 'edittitle'.
        $this['editlink'] = '';
        $this['edittitle'] = '';

        // Initialise the JavaScipt data gateway
        $this['jsdata'] = [];
    }

    protected function initConfig()
    {
        $this->register(new Provider\DatabaseSchemaProvider())
            ->register(new Provider\ConfigServiceProvider());
    }

    protected function initSession()
    {
        $this
            ->register(new Provider\TokenServiceProvider())
            ->register(new SessionServiceProvider(),
                [
                    'session.default_options' => [
                        'cookie_path'     => $this['resources']->getUrl('root'),
                        'cookie_domain'   => $this['config']->get('general/cookies_domain'),
                        'cookie_secure'   => $this['config']->get('general/enforce_ssl'),
                        'cookie_httponly' => true,
                    ],
                    'sessions.options'        => [
                        'main' => [
                            'name' => $this['token.session.name'],
                        ],
                        'csrf' => [
                            'name'                 => $this['token.session.name'] . '_csrf',
                            'cookie_restrict_path' => true,<commit_msg>Using cookies_lifetime from config<commit_after><?php

namespace Bolt;

use Bolt\Debug\DebugToolbarEnabler;
use Bolt\Exception\LowlevelException;
use Bolt\Helpers\Str;
use Bolt\Provider\LoggerServiceProvider;
use Bolt\Provider\PathServiceProvider;
use Bolt\Provider\WhoopsServiceProvider;
use Cocur\Slugify\Bridge\Silex\SlugifyServiceProvider;
use Doctrine\DBAL\DBALException;
use RandomLib;
use SecurityLib;
use Silex;
use Symfony\Component\Security\Csrf\CsrfTokenManager;
use Symfony\Component\Security\Csrf\TokenStorage\SessionTokenStorage;
use Symfony\Component\Stopwatch;

class Application extends Silex\Application
{
    /**
     * The default locale, used as fallback.
     */
    const DEFAULT_LOCALE = 'en_GB';

    /**
     * @param array $values
     */
    public function __construct(array $values = [])
    {
        $values['bolt_version'] = '2.3.0';
        $values['bolt_name'] = 'alpha 1';
        $values['bolt_released'] = false; // `true` for stable releases, `false` for alpha, beta and RC.

        /** @internal Parameter to track a deprecated PHP version */
        $values['deprecated.php'] = version_compare(PHP_VERSION, '5.5.9', '<');

        parent::__construct($values);

        $this->register(new PathServiceProvider());

        // Initialize the config. Note that we do this here, on 'construct'.
        // All other initialisation is triggered from bootstrap.php
        // Warning!
        // One of a valid ResourceManager ['resources'] or ClassLoader ['classloader']
        // must be defined for working properly
        if (!isset($this['resources'])) {
            $this['resources'] = new Configuration\ResourceManager($this);
            $this['resources']->compat();
        } else {
            $this['classloader'] = $this['resources']->getClassLoader();
        }

        $this['resources']->setApp($this);
        $this->initConfig();
        $this->initLogger();
        $this['resources']->initialize();

        $this['debug'] = $this['config']->get('general/debug', false);

        // Initialize the 'editlink' and 'edittitle'.
        $this['editlink'] = '';
        $this['edittitle'] = '';

        // Initialise the JavaScipt data gateway
        $this['jsdata'] = [];
    }

    protected function initConfig()
    {
        $this->register(new Provider\DatabaseSchemaProvider())
            ->register(new Provider\ConfigServiceProvider());
    }

    protected function initSession()
    {
        $this
            ->register(new Provider\TokenServiceProvider())
            ->register(new Provider\SessionServiceProvider(),
                [
                    'session.default_options' => [
                        'cookie_lifetime' => $this['config']->get('general/cookies_lifetime'),
                        'cookie_path'     => $this['resources']->getUrl('root'),
                        'cookie_domain'   => $this['config']->get('general/cookies_domain'),
                        'cookie_secure'   => $this['config']->get('general/enforce_ssl'),
                        'cookie_httponly' => true,
                    ],
                    'sessions.options'        => [
                        'main' => [
                            'name' => $this['token.session.name'],
                        ],
                        'csrf' => [
                            'name'                 => $this['token.session.name'] . '_csrf',
                            'cookie_restrict_path' => true,
                            'cookie_lifetime'      => 0,
{'fraction_non_alphanumeric': 0.14, 'fraction_numerical': 0.002173913043478261, 'mean_word_length': 2.1540219378427787, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 58, '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': '6845005', 'n_tokens_mistral': 1887, 'n_tokens_neox': 1811, 'n_words': 366}