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

Find the hasMany relations and add them to associations list
public findHasMany ( Table $model, array $associations ) : array
$model Cake\ORM\Table Model instance being generated
$associations array Array of in progress associations
Результат array Associations with hasMany added in.
Пример #1
0
 /**
  * test that hasOne and/or hasMany relations are generated properly.
  *
  * @return void
  */
 public function testHasManyGeneration()
 {
     $this->Task->connection = 'test';
     $model = TableRegistry::get('BakeArticles');
     $result = $this->Task->findHasMany($model, []);
     $expected = ['hasMany' => [['alias' => 'BakeComments', 'foreignKey' => 'bake_article_id']]];
     $this->assertEquals($expected, $result);
     $model = TableRegistry::get('CategoryThreads');
     $result = $this->Task->findHasMany($model, []);
     $expected = ['hasMany' => [['alias' => 'ChildCategoryThreads', 'className' => 'CategoryThreads', 'foreignKey' => 'parent_id']]];
     $this->assertEquals($expected, $result);
     $this->Task->plugin = 'Blog';
     $result = $this->Task->findHasMany($model, []);
     $expected = ['hasMany' => [['alias' => 'ChildCategoryThreads', 'className' => 'Blog.CategoryThreads', 'foreignKey' => 'parent_id']]];
     $this->assertEquals($expected, $result);
 }