X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FGenerator%2FPluginTypeAnnotationGenerator.php;fp=vendor%2Fdrupal%2Fconsole%2Fsrc%2FGenerator%2FPluginTypeAnnotationGenerator.php;h=2a5181f1784a7d02e8fe0488858ecfaf06e5b7b5;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/vendor/drupal/console/src/Generator/PluginTypeAnnotationGenerator.php b/vendor/drupal/console/src/Generator/PluginTypeAnnotationGenerator.php new file mode 100644 index 000000000..2a5181f17 --- /dev/null +++ b/vendor/drupal/console/src/Generator/PluginTypeAnnotationGenerator.php @@ -0,0 +1,85 @@ +extensionManager = $extensionManager; + } + + /** + * Generator for Plugin type with annotation discovery. + * + * @param $module + * @param $class_name + * @param $machine_name + * @param $label + */ + public function generate($module, $class_name, $machine_name, $label) + { + $parameters = [ + 'module' => $module, + 'class_name' => $class_name, + 'machine_name' => $machine_name, + 'label' => $label, + 'file_exists' => file_exists($this->extensionManager->getModule($module)->getPath() .'/'.$module.'.services.yml'), + ]; + + $directory = $this->extensionManager->getModule($module)->getSourcePath() . '/Plugin/' . $class_name; + + if (!is_dir($directory)) { + mkdir($directory, 0777, true); + } + + $this->renderFile( + 'module/src/Annotation/plugin-type.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() . '/Annotation/' . $class_name . '.php', + $parameters + ); + + $this->renderFile( + 'module/src/plugin-type-annotation-base.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/Plugin/' . $class_name . 'Base.php', + $parameters + ); + + $this->renderFile( + 'module/src/plugin-type-annotation-interface.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/Plugin/' . $class_name . 'Interface.php', + $parameters + ); + + $this->renderFile( + 'module/src/plugin-type-annotation-manager.php.twig', + $this->extensionManager->getModule($module)->getSourcePath() .'/Plugin/' . $class_name . 'Manager.php', + $parameters + ); + $this->renderFile( + 'module/plugin-annotation-services.yml.twig', + $this->extensionManager->getModule($module)->getPath() . '/' . $module . '.services.yml', + $parameters, + FILE_APPEND + ); + } +}