Nextras\Orm\Repository\IRepository::getMapper PHP Метод

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

public getMapper ( ) : Nextras\Orm\Mapper\IMapper
Результат Nextras\Orm\Mapper\IMapper
    public function getMapper();

Usage Example

Пример #1
0
 public function create($data)
 {
     if ($this->storagePrimaryKey === NULL) {
         $this->storageReflection = $this->repository->getMapper()->getStorageReflection();
         $this->storagePrimaryKey = (array) $this->storageReflection->getStoragePrimaryKey();
     }
     $id = [];
     foreach ($this->storagePrimaryKey as $key) {
         if (!isset($data[$key])) {
             throw new InvalidArgumentException("Data returned from storage does not contain primary value(s) for '{$key}' key.");
         }
         $id[] = $data[$key];
     }
     $id = implode(',', $id);
     if (isset($this->entities[$id]) && $this->entities[$id]) {
         return $this->entities[$id];
     }
     $data = $this->storageReflection->convertStorageToEntity($data);
     $entityClass = $this->repository->getEntityClassName($data);
     if (!isset($this->entityReflections[$entityClass])) {
         $this->entityReflections[$entityClass] = ClassType::from($entityClass);
         $this->entityMetadata[$entityClass] = MetadataStorage::get($entityClass);
     }
     /** @var $entity IEntity */
     $entity = $this->entities[$id] = $this->entityReflections[$entityClass]->newInstanceWithoutConstructor();
     $entity->fireEvent('onLoad', [$this->repository, $this->entityMetadata[$entityClass], $data]);
     return $entity;
 }
All Usage Examples Of Nextras\Orm\Repository\IRepository::getMapper