DataObjectAnnotator
in package
Uses
Injectable, Configurable, Extensible
Class DataObjectAnnotator Generates phpdoc annotations for database fields and orm relations so IDE's with autocompletion and property inspection will recognize properties and relation methods.
The annotations can be generated with dev/build with @see Annotatable and from the @see DataObjectAnnotatorTask
The generation is disabled by default. It is advisable to only enable it in your local dev environment, so the files won't change on a production server when you run dev/build
Table of Contents
Properties
- $dbfield_tagnames : array<string|int, mixed>
- Default tagname will be @string .
- $extension_classes : array<string|int, mixed>
- All classes that subclass Object
- $annotatableClasses : array<string|int, mixed>
- $enabled : bool
- $enabled_modules : array<string|int, mixed>
- $permissionChecker : AnnotatePermissionChecker
Methods
- __construct() : mixed
- DataObjectAnnotator constructor.
- annotateModule() : bool
- Generate docblock for all subclasses of DataObjects and DataExtenions within a module.
- annotateObject() : bool
- Generate docblock for a single subclass of DataObject or DataExtenions
- getClassesForModule() : array<string|int, mixed>
- getExtensionClasses() : array<string|int, mixed>
- isEnabled() : bool
- pushExtensionClass() : mixed
- Add another extension class False checking, because what we get might be uppercase and then lowercase Allowing for duplicates here, to clean up later
- setExtensionClasses() : mixed
- getGeneratedFileContent() : mixed
- Return the complete File content with the newly generated DocBlocks
- setEnabledClasses() : mixed
- Get all annotatable classes from enabled modules
- setupExtensionClasses() : mixed
- Named `setup` to not clash with the actual setter
- writeFileContent() : mixed
Properties
$dbfield_tagnames
Default tagname will be @string .
protected
static array<string|int, mixed>
$dbfield_tagnames
= [\SilverStripe\ORM\FieldType\DBInt::class => 'int', \SilverStripe\ORM\FieldType\DBBoolean::class => 'bool', \SilverStripe\ORM\FieldType\DBFloat::class => 'float', \SilverStripe\ORM\FieldType\DBDecimal::class => 'float']
All exceptions for @see DBField types are listed here
Tags
$extension_classes
All classes that subclass Object
protected
static array<string|int, mixed>
$extension_classes
= []
$annotatableClasses
private
array<string|int, mixed>
$annotatableClasses
= []
$enabled
private
static bool
$enabled
= false
Tags
$enabled_modules
private
static array<string|int, mixed>
$enabled_modules
= ['mysite', 'app']
Tags
$permissionChecker
private
AnnotatePermissionChecker
$permissionChecker
Methods
__construct()
DataObjectAnnotator constructor.
public
__construct() : mixed
Tags
annotateModule()
Generate docblock for all subclasses of DataObjects and DataExtenions within a module.
public
annotateModule(string $moduleName) : bool
Parameters
- $moduleName : string
Tags
Return values
boolannotateObject()
Generate docblock for a single subclass of DataObject or DataExtenions
public
annotateObject(string $className) : bool
Parameters
- $className : string
Tags
Return values
boolgetClassesForModule()
public
getClassesForModule( $moduleName) : array<string|int, mixed>
Parameters
Tags
Return values
array<string|int, mixed>getExtensionClasses()
public
static getExtensionClasses() : array<string|int, mixed>
Return values
array<string|int, mixed>isEnabled()
public
static isEnabled() : bool
Return values
boolpushExtensionClass()
Add another extension class False checking, because what we get might be uppercase and then lowercase Allowing for duplicates here, to clean up later
public
static pushExtensionClass(string $extension_class) : mixed
Parameters
- $extension_class : string
setExtensionClasses()
public
static setExtensionClasses(array<string|int, mixed> $extension_classes) : mixed
Parameters
- $extension_classes : array<string|int, mixed>
getGeneratedFileContent()
Return the complete File content with the newly generated DocBlocks
protected
getGeneratedFileContent(string $fileContent, string $className) : mixed
Parameters
- $fileContent : string
- $className : string
Tags
setEnabledClasses()
Get all annotatable classes from enabled modules
protected
setEnabledClasses(string|StdClass $supportedParentClass) : mixed
Parameters
- $supportedParentClass : string|StdClass
Tags
setupExtensionClasses()
Named `setup` to not clash with the actual setter
protected
setupExtensionClasses() : mixed
Loop all extendable classes and see if they actually have extensions If they do, add it to the array Clean up the array of duplicates Then save the setup of the classes in a static array, this is to save memory
Tags
writeFileContent()
protected
writeFileContent(string $className) : mixed
Parameters
- $className : string