Exemplo n.º 1
0
 /**
  * GetSetAlias. Use to change the system default property names (which might not be overly intuitive) into something more usage.
  *
  * See, @normality.alias[address.contactId]: Addresses
  * Detects collisions.
  *
  * @param data $data
  * @return string $alias
  */
 private function getSetAlias($data, $type)
 {
     // build name
     switch ($type) {
         case 'reference':
             $name = sprintf('%s%s', $data[0], $data[2] ? 's' : '');
             $key = "{$data[0]}.{$data[1]}";
             if (isset($this->normalityTags['alias']['reference'][$key])) {
                 $name = $this->normalityTags['alias']['reference'][$key];
             }
             break;
         case 'data':
             $name = $data;
             break;
         default:
             throw new \InvalidArgumentException("Unknown type for getSetAlias");
     }
     // are we going to ignore this name
     if (strtolower($name) === '__ignore') {
         return null;
     }
     if (in_array($name, $this->getSetAliases)) {
         $message = "Collision on entity {$this->pgClass->getEntityName()} for property {$name}. Don't worry about this.\n";
         echo $message;
         # throw new AliasCollisionException();
     }
     $this->getSetAliases[] = $name;
     return $name;
 }
Exemplo n.º 2
0
 public function buildRelation(PgClass $relation)
 {
     $name = $relation->getEntityName();
     /// logging
     $this->callbacks['log']("{$name} ", false);
     $this->profiler->log($name);
     // construct generators
     if ($relation->isInherited()) {
         $entityBuilderClass = EntityChild::class;
     } else {
         $entityBuilderClass = Entity::class;
     }
     $entityG = new $entityBuilderClass($relation, $this->options->namespaces, $this->options->getPath('entityFileStore'));
     $entityPlaceholderG = new EntityPlaceholder($entityG, $this->options->getNamespace('entityPlaceholder'));
     $repositoryG = new RepositoryG($entityG, $this->options->getNamespace('repository'));
     $repositoryPlaceholderG = new RepositoryPlaceholder($repositoryG, $this->options->getNamespace('repositoryPlaceholder'));
     $this->generate($entityG, true);
     $this->generate($entityPlaceholderG, $this->options->regenerateEntityPlaceholders);
     $this->generate($repositoryG, true);
     $this->generate($repositoryPlaceholderG, $this->options->regenerateRepositoryPlaceholders);
     // register freshly generated entity with Repository
     $namespaces = $this->options->namespaces;
     if ($this->entityManager) {
         $this->entityManager->register($entityPlaceholderG->class->class, $repositoryPlaceholderG->class->class);
     }
     $this->callbacks['log']('');
     return $name;
 }