/** * Initializes the console app by creating the command runner. * * @return null */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath(craft()->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // No need for these. craft()->log->removeRoute('WebLogRoute'); craft()->log->removeRoute('ProfileLogRoute'); // Load the plugins craft()->plugins->loadPlugins(); // Validate some basics on the database configuration file. craft()->validateDbConfigFile(); // Call parent::init before the plugin console command logic so craft()->commandRunner will be available to us. parent::init(); foreach (craft()->plugins->getPlugins() as $plugin) { $commandsPath = craft()->path->getPluginsPath() . StringHelper::toLowerCase($plugin->getClassHandle()) . '/consolecommands/'; if (IOHelper::folderExists($commandsPath)) { craft()->commandRunner->addCommands(rtrim($commandsPath, '/')); } } }
/** * Processes resource requests before anything else has a chance to initialize. */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Initialize HttpRequestService and LogRouter right away $this->getComponent('request'); $this->getComponent('log'); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // If we're not in devMode or this is a resource request, we're going to remove some logging routes. if (!$this->config->get('devMode') || ($resourceRequest = $this->request->isResourceRequest()) == true) { // If it's a resource request, we don't want any logging routes, including craft.log // If it's not a resource request, we'll keep the FileLogRoute around. if ($resourceRequest) { $this->log->removeRoute('FileLogRoute'); } // Don't need either of these if not in devMode or it's a resource request. $this->log->removeRoute('WebLogRoute'); $this->log->removeRoute('ProfileLogRoute'); } parent::init(); }
/** * Initializes the application. * * @return null */ public function init() { // NOTE: Nothing that triggers a database connection should be made here until *after* _processResourceRequest() // in processRequest() is called. // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // If there is a custom validationKey set, apply it here. if ($validationKey = $this->config->get('validationKey')) { $this->security->setValidationKey($validationKey); // Make sure any instances of Yii's CSecurityManager class are using the custom validation // key as well $this->getComponent('securityManager')->setValidationKey($validationKey); } // Attach our own custom Logger Craft::setLogger(new Logger()); // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Set the edition components $this->_setEditionComponents(); parent::init(); }
/** * Initializes the application. * * @return null */ public function init() { // NOTE: Nothing that triggers a database connection should be made here until *after* _processResourceRequest() // in processRequest() is called. // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); // Attach our own custom Logger Craft::setLogger(new Logger()); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } parent::init(); }
/** * @return null */ public function init() { // Set default timezone to UTC date_default_timezone_set('UTC'); // Import all the built-in components foreach ($this->componentAliases as $alias) { Craft::import($alias); } // Attach our Craft app behavior. $this->attachBehavior('AppBehavior', new AppBehavior()); // Initialize Cache, HttpRequestService and LogRouter right away (order is important) $this->getComponent('cache'); $this->getComponent('request'); $this->getComponent('log'); // So we can try to translate Yii framework strings $this->coreMessages->attachEventHandler('onMissingTranslation', array('Craft\\LocalizationHelper', 'findMissingTranslation')); // Set our own custom runtime path. $this->setRuntimePath($this->path->getRuntimePath()); // Attach our own custom Logger Craft::setLogger(new Logger()); // If we're not in devMode, we're going to remove some logging routes. if (!$this->config->get('devMode')) { $this->log->removeRoute('WebLogRoute'); $this->log->removeRoute('ProfileLogRoute'); } // If there is a custom appId set, apply it here. if ($appId = $this->config->get('appId')) { $this->setId($appId); } parent::init(); }