FOF30\Model\DataModel\RelationManager::getData PHP Метод

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

Gets the related items of a relation
См. также: Relation::getData()
public getData ( string $name, callable $callback = null, Collection $dataCollection = null ) : Collection | DataModel
$name string The name of the relation to return data for
$callback callable A callback to customise the returned data
$dataCollection FOF30\Utils\Collection Used when fetching the data of an eager loaded relation
Результат Collection | DataModel
    public function getData($name, $callback = null, \FOF30\Utils\Collection $dataCollection = null)
    {
        if (!isset($this->relations[$name])) {
            throw new DataModel\Relation\Exception\RelationNotFound("Relation '{$name}' not found");
        }
        return $this->relations[$name]->getData($callback, $dataCollection);
    }

Usage Example

Пример #1
0
 /**
  * @group       RelationManager
  * @group       RelationManagerGetData
  * @covers      FOF30\Model\DataModel\RelationManager::getData
  */
 public function testGetDataException()
 {
     $this->setExpectedException('\\FOF30\\Model\\DataModel\\Relation\\Exception\\RelationNotFound');
     $model = $this->buildModel();
     $relation = new RelationManager($model);
     $relation->getData('test');
 }