示例#1
0
 /**
  * Loads Components and prepares them for initialization.
  * Models will be lazy loaded by default
  *
  * @return mixed true if models found and instance created, or cakeError if models not found.
  * @access public
  * @see Controller::loadModel()
  * @link http://book.cakephp.org/view/977/Controller-Methods#constructClasses-986
  */
 function constructClasses()
 {
     if (SlExtensions::getInstance()->dependencyError) {
         $params = SlExtensions::getInstance()->dependencyError;
         SlExtensions::getInstance()->dependencyError = false;
         $this->cakeError('missingDependence', $params);
     }
     SlExtensions::trigger('constructClasses', $this);
     $this->__mergeVars();
     // Component class sets components by reference, hence triggering an uneeded read operation
     // Avoid magic __get() method calls by setting null values
     $this->components = Set::normalize($this->components);
     foreach ($this->components as $component => $settings) {
         if (strpos($component, '.') !== false) {
             list($plugin, $component) = explode('.', $component);
         }
         $this->{$component} = null;
     }
     if (!SlConfigure::read('Sl.options.lazyLoadModels')) {
         return parent::constructClasses();
     }
     $this->Component->init($this);
     if ($this->uses !== null || $this->uses !== array()) {
         if ($this->uses) {
             $uses = is_array($this->uses) ? $this->uses : array($this->uses);
             $modelClassName = $uses[0];
             if (strpos($uses[0], '.') !== false) {
                 list($plugin, $modelClassName) = explode('.', $uses[0]);
             }
             $this->modelClass = $modelClassName;
         }
     }
     return true;
 }
示例#2
0
 *     'plugins' => array('/full/path/to/plugins/', '/next/full/path/to/plugins/'),
 *     'models' =>  array('/full/path/to/models/', '/next/full/path/to/models/'),
 *     'views' => array('/full/path/to/views/', '/next/full/path/to/views/'),
 *     'controllers' => array('/full/path/to/controllers/', '/next/full/path/to/controllers/'),
 *     'datasources' => array('/full/path/to/datasources/', '/next/full/path/to/datasources/'),
 *     'behaviors' => array('/full/path/to/behaviors/', '/next/full/path/to/behaviors/'),
 *     'components' => array('/full/path/to/components/', '/next/full/path/to/components/'),
 *     'helpers' => array('/full/path/to/helpers/', '/next/full/path/to/helpers/'),
 *     'vendors' => array('/full/path/to/vendors/', '/next/full/path/to/vendors/'),
 *     'shells' => array('/full/path/to/shells/', '/next/full/path/to/shells/'),
 *     'locales' => array('/full/path/to/locale/', '/next/full/path/to/locale/')
 * ));
 *
 */
App::build(array('plugins' => array(APP . 'extensions/')));
/**
 * As of 1.3, additional rules for the inflector are added below
 *
 * Inflector::rules('singular', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
 * Inflector::rules('plural', array('rules' => array(), 'irregular' => array(), 'uninflected' => array()));
 *
 */
Cache::config('sl', array('engine' => 'File', 'prefix' => 'sl_', 'duration' => Configure::read() ? '+10 seconds' : '+999 days'));
Cache::config('models', array('engine' => 'File', 'prefix' => 'sl_', 'path' => CACHE . 'models' . DS, 'duration' => '+7 days'));
App::import('lib', 'sl');
App::import('lib', 'sl_configure');
App::import('lib', 'sl_extensions');
App::import('lib', 'sl_session');
App::import('lib', 'sl_cookie');
SlExtensions::trigger('bootstrap');
Configure::write('Routing.prefixes', array_keys(SlConfigure::read('Routing.prefixes')));
示例#3
0
 /**
  * Registers a parser to handle a block in current layout
  *
  * @param string $blockName
  * @param PhemeParser $parser
  * @param string $skin Default (html) skin
  * @param bool $globalContext If true, the registered block could be triggered from layout's {body},
  *      if set to a string the block will be considered a child of the registered block with
  *      that name.
  * @return bool Success or null on error
  */
 public static function register($blockName, $parser = null, $skin = null, $globalContext = true)
 {
     $options = compact('blockName', 'parser', 'skin', 'globalContext');
     $options = SlExtensions::trigger('phemeRegister', $options);
     extract($options);
     // check if not already registered
     if (empty(self::$_registered[$blockName])) {
         // set default skin
         $skin = self::getSkin($skin);
         self::$_core->skins[$blockName] = $skin;
         // register parser
         if (is_string($parser)) {
             $parser = self::get($parser);
         }
         if (!is_object($parser)) {
             return;
         }
         self::$_registered[$blockName] = $parser;
         $parser->options['skinnable'] = true;
         // make block callable from layout's {body}
         if (is_string($globalContext)) {
             $parent = self::get($globalContext);
             $parent->blocks[$blockName] = $parser;
         } elseif ($globalContext) {
             self::$body->blocks[$blockName] = $parser;
         }
         return true;
     }
     return false;
 }