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

Get the true class name of the entity, resolving any proxy wrappers
public static getEntityClassName ( object | string $entity ) : string
$entity object | string
Результат string
Пример #1
0
 /**
  * Get the metadata for an entity, including column information
  *
  * @param string|object $entity Entity or class name of the entity
  * @return Entity
  */
 public function getEntityMetadata($entity)
 {
     $class_name = Reader::getEntityClassName($entity);
     if (!isset($this->metadata_cache[$class_name])) {
         $parser = new AnnotationMetadataParser($class_name);
         $this->metadata_cache[$class_name] = $parser->getEntityMetadata();
     }
     return $this->metadata_cache[$class_name];
 }
Пример #2
0
 public function testStuff()
 {
     $mapper = new AnnotationMapper();
     $product = new Product();
     $product_meta = $mapper->getEntityMetadata(Reader::getEntityClassName($product));
     $this->assertEquals("products", $product_meta->getTableName());
     $bad = new BadEntity();
     $bad_meta = $mapper->getEntityMetadata(Reader::getEntityClassName($bad));
     $this->assertEquals("bad_entity", $bad_meta->getTableName());
 }
Пример #3
0
 /**
  * Get the metadata for an entity, including column information
  *
  * @param string|object $entity Entity or class name of the entity
  * @return Entity
  */
 public function getEntityMetadata($entity)
 {
     foreach ($this->mappers as $mapper) {
         try {
             return $mapper->getEntityMetadata($entity);
         } catch (NoMetadataException $e) {
         }
     }
     if (is_object($entity)) {
         $class = Reader::getEntityClassName($entity);
     } else {
         $class = $entity;
     }
     throw new NoMetadataException("No metadata found for '" . $class . "'");
 }
Пример #4
0
 /**
  * Get the full ID of an entity
  *
  * @param object $entity
  * @return string
  */
 protected function getEntityId($entity)
 {
     $metadata = $this->getMapper()->getEntityMetadata(Reader::getEntityClassName($entity));
     $reader = new Reader($metadata, $entity);
     return $reader->getId();
 }
Пример #5
0
 /**
  * Set entity class name by name or entity object
  *
  * @param string|object $class_name
  * @return void
  */
 public function setClassName($class_name)
 {
     $this->class_name = Reader::getEntityClassName($class_name);
 }
Пример #6
0
 /**
  * Persist an entity
  *
  * @param object $entity Entity object to persist
  * @param int    $ttl    Optional TTL if the driver supports it, seconds past current time
  * @return $this
  */
 public function persist($entity, $ttl = null)
 {
     $metadata = $this->mapper->getEntityMetadata(Reader::getEntityClassName($entity));
     $serialiser = $this->getSerialiserMap()->getDefaultSerialiser();
     $reader = new Reader($metadata, $entity);
     $id = $reader->getId();
     $this->validateId($id);
     if ($ttl) {
         $this->driver->debugLog("Caching " . $metadata->getTableName() . ' ' . $id . ' (TTL: ' . $ttl . ')');
     } else {
         $this->driver->debugLog("Persisting " . $metadata->getTableName() . ' ' . $id);
     }
     $this->driver->persist($this->key_scheme->getEntityKey($metadata->getTableName(), $id), $serialiser->serialise($metadata, $entity), $ttl);
     $this->getRelationshipManager()->persistRelationships($entity, $metadata, $reader, $id);
     $this->getIndexManager()->persistIndices($entity, $metadata, $reader, $id);
     $this->getQueryManager()->persistTableQueries($entity, $metadata, $reader, $id);
     if ($entity instanceof OrmProxyInterface) {
         $entity->setEntityPersisted($id);
     }
     return $this->getProxy();
 }
Пример #7
0
 /**
  * Get the metadata for an entity, including column information
  *
  * If you do not provide a $relative_mapper then relationship metadata will not be hydrated.
  *
  * @param string|object $entity Entity or class name of the entity
  * @return Entity
  */
 public function getEntityMetadata($entity)
 {
     if (is_object($entity)) {
         $class = Reader::getEntityClassName($entity);
     } else {
         $class = $entity;
     }
     $this->processMaps();
     if (array_key_exists($class, $this->entities)) {
         return $this->entities[$class];
     } else {
         throw new NoMetadataException("No metadata is registered for class '" . $class . "'");
     }
 }