Source of file ControllerTagGenerator.php
Size: 1,656 Bytes - Last Modified: 2021-12-23T10:24:49+00:00
/var/www/docs.ssmods.com/process/src/src/Generators/ControllerTagGenerator.php
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 | <?php namespace SilverLeague\IDEAnnotator\Generators; use ReflectionClass; use ReflectionException; use SilverStripe\CMS\Controllers\ContentController; use SilverStripe\Core\ClassInfo; class ControllerTagGenerator extends AbstractTagGenerator { /** * @return void * @throws ReflectionException */ protected function generateTags() { $this->generateControllerObjectTags(); $this->generateExtensionsTags(); $this->generateOwnerTags(); } /** * Generate the controller tags, these differ slightly from the standard ORM tags * * @throws ReflectionException */ protected function generateControllerObjectTags() { $pageClassname = str_replace(['_Controller', 'Controller'], '', $this->className); if (class_exists($pageClassname) && $this->isContentController($this->className)) { $pageClassname = $this->getAnnotationClassName($pageClassname); $this->pushPropertyTag($pageClassname . ' dataRecord'); $this->pushMethodTag('data()', $pageClassname . ' data()'); // don't mixin Page, since this is a ContentController method if ($pageClassname !== 'Page') { $this->pushMixinTag($pageClassname); } } } /** * @param string $className * @return bool * @throws ReflectionException */ protected function isContentController($className) { $reflector = new ReflectionClass($className); return ClassInfo::exists(ContentController::class) && $reflector->isSubclassOf(ContentController::class); } } |