Esempio n. 1
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. 2
0
 /**
  * Does the passed relation pass our test
  */
 public function __invoke(PgClass $relation)
 {
     $tags = $relation->getTags();
     $match = isset($tags['match']) ? $tags['match'] : $relation->name;
     return (bool) preg_match($this->regex, $match);
 }