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); }
/** * @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; }