applyAssociations() публичный Метод

Composer's class cache prevents us from loading the newly generated class. Applying associations if we have a generic table object means fields will be detected correctly.
public applyAssociations ( Table $model, array $associations ) : void
$model Cake\ORM\Table The table to apply associations to.
$associations array The associations to append.
Результат void
Пример #1
0
 /**
  * Test applying associations does nothing on a concrete class
  *
  * @return void
  */
 public function testApplyAssociationsConcreteClass()
 {
     Configure::write('App.namespace', 'Bake\\Test\\App');
     $articles = TableRegistry::get('Articles');
     $assocs = ['belongsTo' => [['alias' => 'BakeUsers', 'foreignKey' => 'bake_user_id']], 'hasMany' => [['alias' => 'BakeComments', 'foreignKey' => 'bake_article_id']], 'belongsToMany' => [['alias' => 'BakeTags', 'foreignKey' => 'bake_article_id', 'joinTable' => 'bake_articles_bake_tags', 'targetForeignKey' => 'bake_tag_id']]];
     $original = $articles->associations()->keys();
     $this->Task->applyAssociations($articles, $assocs);
     $new = $articles->associations()->keys();
     $this->assertEquals($original, $new);
 }