Bravo3\Orm\Mappers\Annotation\AnnotationMetadataParser::getEntityMetadata PHP Method

getEntityMetadata() public method

Get the Entity metadata object
public getEntityMetadata ( boolean $shallow = false ) : Entity
$shallow boolean
return Bravo3\Orm\Mappers\Metadata\Entity
    public function getEntityMetadata($shallow = false)
    {
        $entity = new Entity($this->reflection_obj->name, $this->getTableName());
        $entity->setColumns($this->getColumns());
        if (!$shallow) {
            $entity->setRelationships($this->getRelationships());
        }
        $entity->setIndices($this->getIndices());
        $entity->setSortables($this->getSortables());
        return $entity;
    }

Usage Example

Example #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];
 }