Ejemplo n.º 1
0
 /**
  * Deletes an entity from the repo
  *
  * @param   object $entity The entity to delete
  *
  * @return  void
  *
  * @throws  OrmException  if the entity could not be deleted
  */
 public function remove($entity)
 {
     $idAccessorRegistry = $this->unitOfWork->getEntityRegistry()->getIdAccessorRegistry();
     $entityId = $idAccessorRegistry->getEntityId($entity);
     $this->updateMap();
     if (!in_array($entityId, $this->map)) {
         throw new EntityNotFoundException();
     }
     $colJoinName = $this->relation->colJoinName();
     $mapObject = $this->mapRepository->findOne()->with($colJoinName, Operator::EQUAL, $entityId)->getItem();
     $this->mapRepository->remove($mapObject);
     $this->map = array_diff($this->map, [$entityId]);
 }
Ejemplo n.º 2
0
 /**
  * Create a new entity
  *
  * @param   array $row A hash with the properties for the new entity
  *
  * @return  object
  */
 public function createFromArray(array $row)
 {
     $entities = $this->unitOfWork->getEntityRegistry()->getEntityBuilder()->castToEntity([$row], $this->className);
     return array_shift($entities);
 }
 /**
  * Gets the unit of work's entity registry
  *
  * @return EntityRegistry The entity registry used by the unit of work
  */
 public function getEntityRegistry()
 {
     return $this->unitOfWork->getEntityRegistry();
 }