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

Returns entity class name.
public getEntityClassName ( array $data ) : string
$data array
Результат string
Пример #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;
 }
Пример #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;
 }