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);
     }
 }
Ejemplo n.º 2
0
 /**
  *  Will inject a locale into composite, which locale is
  *  decided by the composite locale option.
  *
  *  @access public
  *  @para CompositeInterface $composite
  */
 public function visitLocaleInjector(CompositeInterface $node)
 {
     if ($node instanceof TypeInterface) {
         # whats the locale
         $locale = $node->getOption('locale');
         if (empty($locale)) {
             throw new CompositeException($node, 'Locale is empty');
         } else {
             # fetch flywight from factory
             $locale = $this->factory->create($locale);
         }
         # assign to the composite
         $node->setLocale($locale);
     }
     return $node;
 }