Nextras\Orm\Repository\Repository::setModel PHP Метод

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

public setModel ( Nextras\Orm\Model\IModel $model )
$model Nextras\Orm\Model\IModel
    public function setModel(IModel $model)
    {
        if ($this->model && $this->model !== $model) {
            throw new InvalidStateException('Repository is already attached.');
        }
        $this->model = $model;
        $this->metadataStorage = $model->getMetadataStorage();
    }

Usage Example

Пример #1
0
 public function setModel(Nextras\Orm\Model\IModel $model)
 {
     parent::setModel($model);
     if ($model instanceof Model) {
         $this->onAfterPersist[] = $this->onBeforeRemove[] = [$model, 'processEntityCache'];
     }
 }