コード例 #1
0
 public function visitGeneratorInjector(CompositeInterface $composite)
 {
     $seed = null;
     if ($composite instanceof SchemaNode) {
         # use the schema setting or keep the default global
         if ($composite->hasOption('randomGenerator') === true) {
             if ($composite->hasOption('generatorSeed') === true) {
                 $seed = $composite->getOption('generatorSeed');
             }
             # re-assign the global
             $this->headGenerator = $this->factory->create($composite->getOption('randomGenerator'), $seed);
         }
         # assign schema the default generator or the custom just setup above
         $composite->setGenerator($this->headGenerator);
     } else {
         # use the schema setting or keep the default global
         if ($composite->hasOption('randomGenerator') === true) {
             if ($composite->hasOption('generatorSeed') === true) {
                 $seed = $composite->getOption('generatorSeed');
             }
             # re-assign the global
             $this->headGenerator = $this->factory->create($composite->getOption('randomGenerator'), $seed);
         } else {
             $this->headGenerator = $composite->getParent()->getGenerator();
         }
         # re-assign the global
         $composite->setGenerator($this->headGenerator);
     }
 }
コード例 #2
0
 public function visitDirectedGraphBuilder(CompositeInterface $composite)
 {
     $builder = $this->pathBuilder;
     $parentNode = $composite->getParent();
     if ($composite instanceof SchemaNode) {
         $this->graph->setRoot($composite);
     } elseif ($composite instanceof TableNode) {
         # if we have a table connect to schema
         $this->graph->connect($builder->buildPath($composite), $composite, $builder->buildPath($parentNode), $parentNode);
     } elseif ($composite instanceof ColumnNode) {
         # if instance of column connect to table
         $this->graph->connect($builder->buildPath($composite), $composite, $builder->buildPath($parentNode), $parentNode);
     } elseif ($composite instanceof FormatterNode) {
         # if instance of formatterNode connect to schema
         $this->graph->connect($builder->buildPath($composite), $composite, $builder->buildPath($parentNode), $parentNode);
     } elseif ($composite instanceof ForeignKeyNode) {
         # if have a fk connect two columns and tables as well as the FKNode to FKColumn
         $finder = new CompositeFinder();
         $parentTable = $finder->set($composite)->parentTable()->get();
         $parentColumn = $finder->set($composite)->parentColumn()->get();
         $fkTableName = $composite->getOption('foreignTable');
         $fkColumnName = $composite->getOption('foreignColumn');
         $fkTable = $finder->set($composite)->table($fkTableName)->get();
         # Does the foreign table exist
         if ($fkTable === null) {
             throw new CompositeException($composite, sprintf('The Foreign Table %s does not exist', $fkTableName));
         }
         # match the column
         $fkColumn = $finder->set($composite)->table($fkTableName)->column($fkColumnName)->get();
         if ($fkColumn === null) {
             return new CompositeException($composite, sprintf('The Foreign Column %s.%s does not exist', $fkTableName, $fkColumnName));
         }
         # a Column could be related to many others for examaple as a composite primary key so
         # the ResultCache can't be attached to a column but instead to the ForeignKeyNode child of the column
         $this->graph->connect($builder->buildPath($composite), $composite, $builder->buildPath($fkColumn), $fkColumn);
         # connect the two columns for easy lookup for Circular Reference checks
         $this->graph->connect($builder->buildPath($parentColumn), $parentColumn, $builder->buildPath($fkColumn), $fkColumn);
         # tables are now related connect them for easy lookup for Circular Reference checks
         $this->graph->connect($builder->buildPath($parentTable), $parentTable, $builder->buildPath($fkTable), $fkTable);
     }
 }