<commit_before><?php
namespace app\modules\core\components;

use Yii;
use yii\base\BootstrapInterface;
use yii\base\Application;
use yii\caching\DbDependency;

class CoreBootstrap implements BootstrapInterface
{
    public $theme;

    public function bootstrap($app)
    {
        $app->on(Application::EVENT_BEFORE_REQUEST, function () {
            /* THEME from database */
            $theme = $this->theme;

            if (!$theme) {
                $duration = null;
                $dependency = new DbDependency(['sql' => 'SELECT MAX(updated_at) FROM {{%setting}}']);
                $result = Yii::$app->db->cache(function ($db) {
                    return Yii::$app->db->createCommand("SELECT param_value FROM {{%setting}} WHERE module_id='core' AND param_key = 'theme'")->queryOne();
                }, $duration, $dependency);
                $theme = $result['param_value'];
            }

            Yii::setAlias('theme', '@app/themes/' . $theme);
            Yii::$app->view->theme = Yii::createObject([
                'class' => '\yii\base\Theme',
                'pathMap' => ['@app/views' => '@app/themes/' . $theme],
                'baseUrl' => '@web/themes/' . $theme,
            ]);
        });
    }
}<commit_msg>Core Module v.0.0.1: x: CoreBootstrap - theme not found or missing in the database<commit_after><?php
namespace app\modules\core\components;

use Yii;
use yii\base\BootstrapInterface;
use yii\base\Application;
use yii\base\Exception;
use yii\caching\DbDependency;
use yii\helpers\FileHelper;

class CoreBootstrap implements BootstrapInterface
{
    public $theme;

    public function bootstrap($app)
    {
        $app->on(Application::EVENT_BEFORE_REQUEST, function () {
            /* Set current THEME */
            $theme = $this->theme;

            if (!$theme) {
                $duration = null;
                $dependency = new DbDependency(['sql' => 'SELECT MAX(updated_at) FROM {{%setting}}']);
                $result = Yii::$app->db->cache(function ($db) {
                    return Yii::$app->db->createCommand("SELECT param_value FROM {{%setting}} WHERE module_id='core' AND param_key = 'theme'")->queryOne();
                }, $duration, $dependency);
                $theme = $result['param_value'];
                if (!$theme)
                    return false;
            }

            if (file_exists('@app/themes/' . $theme)) {
                Yii::setAlias('theme', '@app/themes/' . $theme);
                Yii::$app->view->theme = Yii::createObject([
                    'class' => '\yii\base\Theme',
                    'pathMap' => ['@app/views' => '@app/themes/' . $theme],
                    'baseUrl' => '@web/themes/' . $theme,
                ]);
            }
        });
    }
}
{'fraction_non_alphanumeric': 0.1614771904417089, 'fraction_numerical': 0.0010861694424330196, 'mean_word_length': 2.0, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 31, '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': '120044', 'n_tokens_mistral': 812, 'n_tokens_neox': 777, 'n_words': 161}