Example #1
0
 /**
  * Process a model recursively and pull out all the
  * model names converting them to fixture names.
  *
  * @param Model $subject A Model class to scan for associations and pull fixtures off of.
  * @return void
  */
 protected function _processModel($subject)
 {
     $this->_addFixture($subject->alias());
     foreach ($subject->associations()->keys() as $alias) {
         $assoc = $subject->association($alias);
         $target = $assoc->target();
         $name = $target->alias();
         $subjectClass = get_class($subject);
         if ($subjectClass !== 'Cake\\ORM\\Table' && $subjectClass === get_class($target)) {
             continue;
         }
         if (!isset($this->_fixtures[$name])) {
             $this->_processModel($target);
         }
         if ($assoc->type() === Association::MANY_TO_MANY) {
             $junction = $assoc->junction();
             if (!isset($this->_fixtures[$junction->alias()])) {
                 $this->_processModel($junction);
             }
         }
     }
 }
Example #2
0
 /**
  * Process a model recursively and pull out all the
  * model names converting them to fixture names.
  *
  * @param Model $subject A Model class to scan for associations and pull fixtures off of.
  * @return void
  */
 protected function _processModel($subject)
 {
     $this->_addFixture($subject->alias());
     foreach ($subject->associations()->keys() as $alias) {
         $assoc = $subject->association($alias);
         $name = $assoc->target()->alias();
         if (!isset($this->_fixtures[$name])) {
             $this->_processModel($assoc->target());
         }
         if ($assoc->type() === Association::MANY_TO_MANY) {
             $junction = $assoc->junction();
             if (!isset($this->_fixtures[$junction->alias()])) {
                 $this->_processModel($junction);
             }
         }
     }
 }