示例#1
0
 /**
  * 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, '/'));
         }
     }
 }
 /**
  * Initializes the console application and setup some event handlers
  */
 protected function init()
 {
     parent::init();
     $this->interceptor->start();
     $this->moduleManager->start();
     $this->interceptor->intercept($this);
     if ($this->hasEventHandler('onInit')) {
         $this->onInit(new CEvent($this));
     }
     $this->setupRequestInfo();
 }
示例#3
0
 /**
  *
  */
 public function init()
 {
     // Set default timezone to UTC
     date_default_timezone_set('UTC');
     foreach ($this->componentAliases as $alias) {
         Craft::import($alias);
     }
     craft()->getComponent('log');
     // Set our own custom runtime path.
     $this->setRuntimePath(craft()->path->getRuntimePath());
     // No need for these.
     craft()->log->removeRoute('WebLogRoute');
     craft()->log->removeRoute('ProfileLogRoute');
     // Load the plugins
     craft()->plugins->loadPlugins();
     parent::init();
 }
示例#4
0
文件: App.php 项目: ostark/schematic
 /**
  * Initializes the console app by creating the command runner.
  */
 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('SchematicBehavior', new Schematic());
     // Attach our own custom Logger
     Craft::setLogger(new Logger());
     // 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', ['Craft\\LocalizationHelper', 'findMissingTranslation']);
     // Set our own custom runtime path.
     $this->setRuntimePath(Craft::app()->path->getRuntimePath());
     // No need for these.
     Craft::app()->log->removeRoute('WebLogRoute');
     Craft::app()->log->removeRoute('ProfileLogRoute');
     // Set the edition components
     $this->_setEditionComponents();
     // Install Craft if needed
     if (!$this->isInstalled()) {
         $this->_installCraft();
     }
     // Set the schematic components
     $this->_setSchematicComponents();
     // Call parent::init() before the plugin console command logic so the command runner gets initialized
     parent::init();
     // Load the plugins
     Craft::app()->plugins->loadPlugins();
     // Validate some basics on the database configuration file.
     Craft::app()->validateDbConfigFile();
     // Add commands
     Craft::app()->commandRunner->commands = [];
     Craft::app()->commandRunner->addCommands(__DIR__ . '/../ConsoleCommands/');
 }