Source of file MakeForm.php
Size: 2,451 Bytes - Last Modified: 2023-11-16T22:56:03+01:00
/home/websites/teicee/packagist/site/phpdoc/conf/../vendor/teicee/make-bundle/src/Maker/MakeForm.php
| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071 | <?phpnamespace TIC\MakeBundle\Maker; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Input\InputArgument; use Symfony\Bundle\MakerBundle\Util\ClassNameDetails; use Symfony\Bundle\MakerBundle\Exception\RuntimeCommandException; use Symfony\Bundle\MakerBundle\Doctrine\DoctrineHelper; use TIC\MakeBundle\Renderer\FormTypeRenderer; /** * */final class MakeForm extends BaseMaker {private $doctrineHelper; private $formTypeRenderer; public function __construct(DoctrineHelper $doctrineHelper, FormTypeRenderer $formTypeRenderer) { parent::__construct(); $this->doctrineHelper = $doctrineHelper; $this->formTypeRenderer = $formTypeRenderer; } /** * Configure the command: set description, input arguments, options, etc. */protected function ticConfigure(Command $command) { $command->addArgument('name', InputArgument::OPTIONAL, "Nom, chemin ou classname du formulaire (<folder?>/entity)"); } /** * Called after normal code generation: allows you to do anything. */protected function ticGenerate(InputInterface $input) { $inputName = $this->fixClassName($input->getArgument('name')); $this->io->title("Construction du formulaire : '$inputName'"); // détermination des variables à utiliser $variables = $this->getVariablesFromName($inputName, "Type"); $doctrineDetails = $this->doctrineHelper->createDoctrineDetails($variables['item_class']); $entityDetails = new ClassNameDetails($variables['item_class'], ''); $formDetails = new ClassNameDetails($variables['form_class'], ''); // affichage des valeurs des variables $this->io->section("Paramètres utilisés :"); $this->io->table(["Variable","Valeur"], self::hash2list($variables)); if (null === $doctrineDetails) throw new RuntimeCommandException("Entité introuvable : " . $variables['item_class']); if ($this->test) return; if (! $this->confirm("Lancer la construction ?")) return; $results = array(); // construction FormType $this->io->section("Construction du formulaire..."); $formPath = $this->ticGenerateFormType($this->formTypeRenderer, $formDetails, $doctrineDetails, $entityDetails); $results[] = [ $variables['form_class'], $formPath ]; $this->io->success("Génération du FormType : " . $variables['form_class']); // récapitulatif des fichiers générés return $this->summary($results); } } |