Esempio n. 1
0
 /**
  * Standard constructor
  * @param $entityName
  */
 public function __construct($entityClass, EntityManager $em)
 {
     $this->entity = get_unqualified_class($entityClass);
     $this->entityClass = $entityClass;
     $this->entityNamespace = get_namespace($entityClass);
     $this->entityManager = $em;
     $this->db = $this->entityManager->db;
     $this->reflEntityClass = new \ReflectionClass($this->entityClass);
     // entities might not have the property entityManager accessible
     try {
         $this->reflEntityManagerPropertyOfEntity = $this->reflEntityClass->getProperty('entityManager');
         $this->reflEntityManagerPropertyOfEntity->setAccessible(true);
     } catch (\ReflectionException $e) {
         $this->reflEntityManagerPropertyOfEntity = null;
     }
     foreach ($this->dataTypes as &$dataType) {
         $dataType = DataType::unserialize($dataType);
     }
 }
Esempio n. 2
0
    /**
     * Standard constructor
     */
    public function __construct(PgClass $pgClass, array $options, $entityFileStoreBase = null)
    {
        $this->pgClass = $pgClass;
        $this->options = $options;
        $this->entityFileStore = $entityFileStoreBase . '/' . $this->pgClass->getEntityName();
        $this->class = new PhpClass($this->pgClass->getEntityName(), $options['entity'], false);
        $this->references = $this->pgClass->getReferences();
        $this->normalityTags = $this->pgClass->getTags();
        $this->dataTypes = DataType::makeFromRelation($this->pgClass);
        $this->loadUnsettableProperties();
        $this->loadLateLoadProperty();
        $this->loadKeyProperties();
        // create entity filestore directory structure.
        if (!is_dir($this->entityFileStore)) {
            mkdir($this->entityFileStore, 0755, true);
        }
        // readonly property
        if ($this->pgClass->isLogTable()) {
            $this->isReadOnly = 'READONLY_ON_PERSIST';
        }
        if ($this->pgClass->isView() or $this->pgClass->isMaterialisedView()) {
            $this->isReadOnly = 'READONLY_EXCEPTION';
        }
        if (array_key_exists('isReadOnly', $this->normalityTags)) {
            $this->isReadOnly = $this->normalityTags['isReadOnly'];
        }
        //         $this->class->classComponents[] = new ClassConstant(
        //             'REPOSITORY_NAMESPACE',
        //             new Sformatf( <<<'PHP'
        //                     /**
        //                      * Repository Location
        //                      */
        //                     const REPOSITORY_NAMESPACE = '%s';
        // PHP
        //                 , addslashes( $this->options['repository'] )
        //             )
        //         );
        $this->class->classComponents[] = new ClassConstant('ENTITY_FILESTORE', new Sformatf(<<<'PHP'
                /**
                 * Entity FileStore directory
                 */
                const ENTITY_FILESTORE = '%s';
PHP
, addslashes($this->entityFileStore)));
        $this->getClassExtends();
        $this->getGetSetFunction();
        $this->getSqlInterfaceFunction();
        $this->setClassComment();
        $this->getUnsettablePropertiesDeclaration();
        $this->getAdditionalPropertiesDeclaration();
        $this->getLateLoadPropertyDeclaration();
        $this->getKeyPropertiesDeclaration();
        $this->getIsReadOnlyPropertyDeclaration();
        $this->getDataDeclaration();
        $this->getIsZombieFunction();
        $this->getSymfonyloadValidatorMetadataFunction();
    }
Esempio n. 3
0
 public function testEntityWithInheritance()
 {
     $catalog = new Catalog($this->connectionFactory->get('RW'));
     $datatype = DataType::makeFromAttribute($catalog->pgAttributes->findByIdentifier('ref_a1_child.a1_child_id'));
     $this->assertTrue($datatype->isNormalityEntity($entity));
     $this->assertSame($entity, 'A1child');
 }