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

Attaches entity to repository.
public attach ( Nextras\Orm\Entity\IEntity $entity )
$entity Nextras\Orm\Entity\IEntity
Пример #1
0
 public function __construct(Nextras\Orm\Entity\IEntity $entity, Nextras\Orm\Repository\IRepository $repository)
 {
     parent::__construct();
     $this->entity = $entity;
     $this->repository = $repository;
     $this->metadata = $entity->getMetadata();
     $this->mapper = $repository->getMapper();
     $this->model = $repository->getModel();
     $this->monitor(Ytnuk\Orm\Form::class);
     $repository->attach($entity);
 }
Пример #2
0
 /**
  * @param  array
  * @return IEntity
  */
 protected function createEntity(array $data)
 {
     $data = $this->storageReflection->convertStorageToEntity($data);
     $entityClass = $this->repository->getEntityClassName($data);
     if (!isset($this->entityReflections[$entityClass])) {
         $this->entityReflections[$entityClass] = ClassType::from($entityClass);
     }
     $entity = $this->entityReflections[$entityClass]->newInstanceWithoutConstructor();
     $this->repository->attach($entity);
     $entity->fireEvent('onLoad', [$data]);
     return $entity;
 }