示例#1
0
文件: App.php 项目: ostark/schematic
 /**
  * Override getComponent() so we can attach any pending events if the component is getting initialized as well as
  * do some special logic around creating the `Craft::app()->db` application component.
  *
  * @param string $id
  * @param bool   $createIfNull
  *
  * @return mixed
  */
 public function getComponent($id, $createIfNull = true)
 {
     $component = parent::getComponent($id, false);
     if (!$component && $createIfNull) {
         if ($id === 'db') {
             $dbConnection = $this->asa('SchematicBehavior')->createDbConnection();
             $this->setComponent('db', $dbConnection);
         }
         $component = parent::getComponent($id, true);
         $this->_attachEventListeners($id);
     }
     return $component;
 }