|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
namespace SilverLeague\IDEAnnotator; |
|
4
|
|
|
|
|
5
|
|
|
use Psr\Container\NotFoundExceptionInterface; |
|
6
|
|
|
use SilverStripe\Control\Director; |
|
7
|
|
|
use SilverStripe\Core\Config\Config; |
|
8
|
|
|
use SilverStripe\Core\Extension; |
|
9
|
|
|
use SilverStripe\Core\Injector\Injector; |
|
10
|
|
|
|
|
11
|
|
|
/** |
|
12
|
|
|
* Class Annotatable |
|
13
|
|
|
* |
|
14
|
|
|
* Annotate extension for the provided DataObjects for autocompletion purposes. |
|
15
|
|
|
* Start annotation, if skipannotation is not set and the annotator is enabled. |
|
16
|
|
|
* |
|
17
|
|
|
* @package IDEAnnotator/Extensions |
|
18
|
|
|
* @property \SilverStripe\Dev\DevBuildController|\SilverLeague\IDEAnnotator\Annotatable $owner |
|
19
|
|
|
*/ |
|
20
|
|
|
class Annotatable extends Extension |
|
21
|
|
|
{ |
|
22
|
|
|
|
|
23
|
|
|
/** |
|
24
|
|
|
* Keep track ot the annotation actions for extensions |
|
25
|
|
|
* An Extension can belong to many DataObjects. |
|
26
|
|
|
* This prevents that an Extension is ran twice on dev/build |
|
27
|
|
|
* @var array |
|
28
|
|
|
*/ |
|
29
|
|
|
public static $annotated_extensions = []; |
|
30
|
|
|
/** |
|
31
|
|
|
* @var DataObjectAnnotator |
|
32
|
|
|
*/ |
|
33
|
|
|
protected $annotator; |
|
34
|
|
|
/** |
|
35
|
|
|
* @var AnnotatePermissionChecker |
|
36
|
|
|
*/ |
|
37
|
|
|
protected $permissionChecker; |
|
38
|
|
|
|
|
39
|
|
|
/** |
|
40
|
|
|
* Annotated Controllers and Extensions |
|
41
|
|
|
* @throws NotFoundExceptionInterface |
|
42
|
|
|
*/ |
|
43
|
|
|
public function afterCallActionHandler() |
|
44
|
|
|
{ |
|
45
|
|
|
$this->setUp(); |
|
46
|
|
|
|
|
47
|
|
|
$skipAnnotation = $this->owner->getRequest()->getVar('skipannotation'); |
|
|
|
|
|
|
48
|
|
|
$envIsAllowed = Director::isDev() && Config::inst()->get(DataObjectAnnotator::class, 'enabled'); |
|
49
|
|
|
|
|
50
|
|
|
if ($skipAnnotation === null && $envIsAllowed) { |
|
51
|
|
|
$this->displayMessage("<div class='build'><p><b>Generating class docblocks</b></p><ul>\n\n"); |
|
52
|
|
|
|
|
53
|
|
|
$modules = $this->permissionChecker->enabledModules(); |
|
54
|
|
|
foreach ($modules as $module) { |
|
55
|
|
|
$this->annotator->annotateModule($module); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$this->displayMessage("</ul>\n<p><b>Docblock generation finished!</b></p></div>"); |
|
59
|
|
|
} |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Annotatable setup. |
|
64
|
|
|
* This is theoretically a constructor, but to save memory we're using setup called from {@see requireDefaultRecords} |
|
65
|
|
|
* @throws NotFoundExceptionInterface |
|
66
|
|
|
*/ |
|
67
|
|
|
public function setUp() |
|
68
|
|
|
{ |
|
69
|
|
|
$this->annotator = Injector::inst()->get(DataObjectAnnotator::class); |
|
70
|
|
|
$this->permissionChecker = Injector::inst()->get(AnnotatePermissionChecker::class); |
|
71
|
|
|
} |
|
72
|
|
|
|
|
73
|
|
|
/** |
|
74
|
|
|
* @param $message |
|
75
|
|
|
*/ |
|
76
|
|
|
public function displayMessage($message) |
|
77
|
|
|
{ |
|
78
|
|
|
echo Director::is_cli() ? "\n" . $message . "\n\n" : "<p><b>$message</b></p>"; |
|
79
|
|
|
} |
|
80
|
|
|
} |
|
81
|
|
|
|
This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.
This is most likely a typographical error or the method has been renamed.