コード例 #1
0
 /**
  * Loads a extension and initializes it <br><br>
  *
  * If the hook return false the extension is deactivated for current controller instance
  *
  * @param string $name
  * @param array $settings
  * @param bool $loadConfig
  * @return bool
  */
 protected function _load($name, $settings = null, $loadConfig = true)
 {
     $extensionPath = APP . 'extensions/' . Inflector::underscore($name) . '/';
     /*App::build(
           'locales' => array(
           'localePaths', am(Configure::read('localePaths'), array($extensionPath.'locale/')))
       );*/
     if ($loadConfig) {
         SlConfigure::load("{$extensionPath}config/" . Inflector::underscore($name) . ".php");
     }
     $extensionPath .= Inflector::underscore($name) . '_extension.php';
     $name = Inflector::camelize($name);
     $className = $name . 'Extension';
     if (in_array($name, $this->_loaded)) {
         return true;
     }
     if (is_readable($extensionPath)) {
         include_once $extensionPath;
     }
     if (class_exists($className)) {
         $this->_loaded[] = $name;
         $this->{$name} = new $className();
         return true;
     }
     return false;
 }