FOF30\Model\DataModel\Relation::getData PHP Method

getData() public method

If you want to apply additional filtering to the foreign model, use the $callback. It can be any function, static method, public method or closure with an interface of function(DataModel $foreignModel). You are not supposed to return anything, just modify $foreignModel's state directly. For example, you may want to do: $foreignModel->setState('foo', 'bar')
public getData ( callable $callback = null, Collection $dataCollection = null ) : Collection | DataModel
$callback callable The callback to run on the remote model.
$dataCollection Collection
return Collection | DataModel
    public function getData($callback = null, Collection $dataCollection = null)
    {
        if (is_null($this->data)) {
            // Initialise
            $this->data = new Collection();
            // Get a model instance
            $foreignModel = $this->getForeignModel();
            $foreignModel->setIgnoreRequest(true);
            $filtered = $this->filterForeignModel($foreignModel, $dataCollection);
            if (!$filtered) {
                return $this->data;
            }
            // Apply the callback, if applicable
            if (!is_null($callback) && is_callable($callback)) {
                call_user_func($callback, $foreignModel);
            }
            // Get the list of items from the foreign model and cache in $this->data
            $this->data = $foreignModel->get(true);
        }
        return $this->data;
    }