// If the plugin’s version just changed, make sure the old version is >= the min allowed version if ( $hasVersionChanged && isset($plugin->minVersionRequired) && $plugin->minVersionRequired && !str_starts_with($row['version'], 'dev-') && !str_ends_with($row['version'], '-dev') && version_compare($row['version'], $plugin->minVersionRequired, '<') ) { throw new HttpException(200, Craft::t('app', 'You need to be on at least {plugin} {version} before you can update to {plugin} {targetVersion}.', [ 'version' => $plugin->minVersionRequired, 'targetVersion' => $plugin->version, 'plugin' => $plugin->name, ])); } // If we're not updating, check if the plugin’s version number changed, but not its schema version. if (!Craft::$app->getIsInMaintenanceMode() && $hasVersionChanged && !$this->isPluginUpdatePending($plugin)) { // Update our record of the plugin’s version number
$this->_registerFieldLayoutListener(); // Register all the listeners for config items $this->_registerConfigListeners(); // Load the plugins $this->getPlugins()->loadPlugins(); $this->_isInitialized = true; // Fire an 'init' event if ($this->hasEventHandlers(WebApplication::EVENT_INIT)) { $this->trigger(WebApplication::EVENT_INIT);
parent::init(); if (!App::isEphemeral()) { $this->ensureResourcePathExists(); } $this->_postInit(); $this->authenticate(); $this->debugBootstrap(); } /** * @inheritdoc
*/ public function __construct($config = []) { if (!empty($config)) { Yii::configure($this, $config); } $this->init(); } /** * Initializes the object. * This method is invoked at the end of the constructor after the object is initialized with the * given configuration.
$this->state = self::STATE_BEGIN; $this->preInit($config); $this->registerErrorHandler($config); Component::__construct($config); } /** * Pre-initializes the application. * This method is called at the beginning of the application constructor. * It initializes several important application properties.
$config = $this->resolveDependencies($config); if (!empty($dependencies) && $reflection->implementsInterface('yii\base\Configurable')) { // set $config as the last parameter (existing one will be overwritten) $dependencies[count($dependencies) - 1] = $config; return $reflection->newInstanceArgs($dependencies); } $object = $reflection->newInstanceArgs($dependencies); foreach ($config as $name => $value) { $object->$name = $value; }
$class = $class->id; } if (isset($this->_singletons[$class])) { // singleton return $this->_singletons[$class]; } elseif (!isset($this->_definitions[$class])) { return $this->build($class, $params, $config); } $definition = $this->_definitions[$class]; if (is_callable($definition, true)) { $params = $this->resolveDependencies($this->mergeParams($class, $params));
return static::$container->get($class, $params, $type); } if (isset($type['class'])) { $class = $type['class']; unset($type['class']); return static::$container->get($class, $params, $type); } throw new InvalidConfigException('Object configuration must be an array containing a "class" or "__class" element.'); } private static $_logger;
public static function createObject($type, array $params = []) { if (is_array($type) && isset($type['__class']) && isset($type['class'])) { throw new InvalidConfigException('`__class` and `class` cannot both be specified.'); } return parent::createObject($type, $params); } /** * Checks if a string references an environment variable (`$VARIABLE_NAME`) * and/or an alias (`@aliasName`), and returns the referenced value. *
if (function_exists('craft_modify_app_config')) { craft_modify_app_config($config, $appType); } // Initialize the application /** @var \craft\web\Application|craft\console\Application $app */ $app = Craft::createObject($config); // If there was a max_input_vars error, kill the request before we start processing it with incomplete data if ($lastError && strpos($lastError['message'], 'max_input_vars') !== false) { throw new ErrorException($lastError['message']); }
// Load Craft // ----------------------------------------------------------------------------- $appType = 'web'; return require __DIR__ . '/bootstrap.php';
// (see https://craftcms.com/docs/3.x/config/#php-constants) define('CRAFT_ENVIRONMENT', getenv('ENVIRONMENT') ?: 'production'); // ... // Load and run Craft /** @var craft\web\Application $app */ $app = require CRAFT_VENDOR_PATH . '/craftcms/cms/bootstrap/web.php'; $app->run();