/** * {@inheritdoc} */ public function dispatch($generator, $arguments, $path = null, $simulate = false) { if (is_string($generator)) { $generator = $this->registry->getGenerator($generator); } if (is_array($arguments)) { $arguments = new Arguments($arguments); } $generator->before($arguments); $constraints = $generator->getConstraints(); // retrieve interactive input if ($arguments->isForcedInteractive()) { $questioner = new Questioner($this->getInputTypeRegistry(), $this->getOutput(), $this->getHelperSet(), $constraints, $this->validator); $generator->beforeInteract($arguments); $generator->interact($arguments, $questioner); } // run validation $generator->beforeValidate($arguments); $constraints = new Collection($constraints); $constraints->allowExtraFields = true; $problems = $this->validator->validateValue($arguments->getData(), $constraints); // stop if any problems are found if (count($problems) > 0) { $this->showValidationProblems($problems, $generator); throw new ValidationException("Generator failed because of validation errors"); } // create a builder for this specific generator $generator->beforeGenerate($arguments); $builder = $this->builder->forGenerator($generator, $arguments); if ($path !== null) { $builder = $builder->withPath($path); } $builder->simulated($simulate); // run the generator $generator->setOutput($this->output); $generator->generate($arguments, $builder, $this); }