Example #1
0
 /**
  * Overrides Model::__constructLinkedModel() so it won't instantiate the entire model chain. It will only
  * instantiate the HABTM associations that use an automodel, because there are two models needed to figure
  * out what the name is of the join model. To avoid this, use your own join model using `with` or don't use
  * HABTM at all.
  *
  * @param string $assoc Association name.
  * @param string $className Class name.
  * @return void
  * @access public
  */
 public function __constructLinkedModel($assoc, $className = null)
 {
     if (!isset($this->map[$assoc])) {
         parent::__constructLinkedModel($assoc, $className);
     }
 }
Example #2
0
 /**
  * Private helper method to create associated models of a given class.
  *
  * @param string $assoc Association name
  * @param string $className Class name
  * @deprecated $this->$className use $this->$assoc instead. $assoc is the 'key' in the associations array;
  * 	examples: var $hasMany = array('Assoc' => array('className' => 'ModelName'));
  * 					usage: $this->Assoc->modelMethods();
  *
  * 				var $hasMany = array('ModelName');
  * 					usage: $this->ModelName->modelMethods();
  * @return void
  * @access private
  */
 function __constructLinkedModel($assoc, $className = null)
 {
     if (!SlConfigure::read('Sl.options.lazyLoadModels')) {
         return parent::__constructLinkedModel($assoc, $className);
     }
     if (empty($className)) {
         $className = $assoc;
     }
     $this->_lazyLoaderBusy = true;
     if (!isset($this->{$assoc}) || $this->{$assoc}->name !== $className) {
         $model = array('class' => $className, 'alias' => $assoc);
         $this->_lazyLoadedModels[$assoc] = $model;
         // <-- the magic starts here
     }
     $this->_lazyLoaderBusy = false;
 }