Source of file DataObjectAnnotatorTask.php
Size: 1,802 Bytes - Last Modified: 2021-12-23T10:24:49+00:00
/var/www/docs.ssmods.com/process/src/src/Tasks/DataObjectAnnotatorTask.php
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 | <?php namespace SilverLeague\IDEAnnotator\Tasks; use Psr\Container\NotFoundExceptionInterface; use ReflectionException; use SilverLeague\IDEAnnotator\DataObjectAnnotator; use SilverLeague\IDEAnnotator\Helpers\AnnotatePermissionChecker; use SilverStripe\Control\HTTPRequest; use SilverStripe\Core\Injector\Injector; use SilverStripe\Dev\BuildTask; /** * Class DataObjectAnnotatorTask * * Task to add or remove annotations from a module or dataobject. * * @package IDEAnnotator/Tasks */ class DataObjectAnnotatorTask extends BuildTask { /** * DataObjectAnnotatorTask constructor. * Setup default values. In this case title and description. */ public function __construct() { parent::__construct(); $this->title = 'DataObject annotations for specific DataObjects, Extensions or Controllers'; $this->description = 'DataObject Annotator annotates your DO\'s if possible,' . ' helping you write better code.' . '<br />Usage: add the module or DataObject as parameter to the URL,' . ' e.g. ?module=mysite'; } /** * @param HTTPRequest $request * @return bool * @throws ReflectionException * @throws NotFoundExceptionInterface */ public function run($request) { /* @var $permissionChecker AnnotatePermissionChecker */ $permissionChecker = Injector::inst()->get(AnnotatePermissionChecker::class); if (!$permissionChecker->environmentIsAllowed()) { return false; } /* @var $annotator DataObjectAnnotator */ $annotator = DataObjectAnnotator::create(); $annotator->annotateObject($request->getVar('object')); $annotator->annotateModule($request->getVar('module')); return true; } } |