/**
  * {@inheritdoc}
  */
 public function locate($resource, GeneratorInterface $generator)
 {
     $location = $this->location;
     if ($location[-1] !== '/' && $location[-1] !== '\\') {
         $location .= '/';
     }
     if (strpos($location, '%generator%') !== false) {
         $directory = str_replace('%generator%', $generator->getName(), $location);
     } else {
         $directory = $location . $generator->getName() . '/';
     }
     return $directory . $resource;
 }
Ejemplo n.º 2
0
 /**
  * {@inheritdoc}
  */
 public function addGenerator(GeneratorInterface $generator, $priority = 1)
 {
     $name = $generator->getName();
     if (!$this->hasGenerator($name) || $this->priorities[$name] < $priority) {
         $this->generators[$name] = $generator;
         $this->priorities[$name] = $priority;
     }
 }
 public static function format(ConstraintViolationList $problems, GeneratorInterface $generator, FormatterHelper $formatter)
 {
     $messages = [];
     // add header message
     $problemCount = count($problems);
     $name = $generator->getName();
     $messages[] = "While trying to call the generator '{$name}', {$problemCount} problems were found:";
     $messages[] = "";
     /** @var ConstraintViolation $problem */
     foreach ($problems as $problem) {
         $messages[] = "In \$arguments{$problem->getPropertyPath()}: {$problem->getMessage()}";
     }
     return $formatter->formatBlock($messages, 'error', true);
 }
Ejemplo n.º 4
0
 /**
  * Show the help for a single generator.
  * @param GeneratorInterface $generator
  * @param OutputInterface    $output
  */
 protected function showGeneratorHelp(GeneratorInterface $generator, OutputInterface $output)
 {
     $definition = new InputDefinition($generator->getDefinition());
     $output->writeln("<comment>Generator:</comment> <info>{$generator->getName()}</info>");
     $output->writeln(" {$generator->getDescription()}");
     $output->writeln("");
     $output->writeln("<comment>Usage:</comment>");
     $output->writeln(" {$this->getName()} {$generator->getName()} {$definition->getSynopsis()}");
     $output->writeln("");
     $descriptor = new DescriptorHelper();
     $descriptor->describe($output, $definition);
 }