SilverStripe Search

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
see

generateDBTags();

config

Can be overridden via config

$extension_classes

All classes that subclass Object

protected static array<string|int, mixed> $extension_classes = []

$enabled

private static bool $enabled = false
Tags
config

Enable generation from @see Annotatable and @see DataObjectAnnotatorTask

$enabled_modules

private static array<string|int, mixed> $enabled_modules = ['mysite', 'app']
Tags
config

Enable modules that are allowed to have generated docblocks for DataObjects and DataExtensions

Methods

__construct()

DataObjectAnnotator constructor.

public __construct() : mixed
Tags
throws
NotFoundExceptionInterface
throws
ReflectionException

annotateModule()

Generate docblock for all subclasses of DataObjects and DataExtenions within a module.

public annotateModule(string $moduleName) : bool
Parameters
$moduleName : string
Tags
throws
ReflectionException
throws
NotFoundExceptionInterface
Return values
bool

annotateObject()

Generate docblock for a single subclass of DataObject or DataExtenions

public annotateObject(string $className) : bool
Parameters
$className : string
Tags
throws
InvalidArgumentException
throws
ReflectionException
throws
NotFoundExceptionInterface
Return values
bool

getClassesForModule()

public getClassesForModule( $moduleName) : array<string|int, mixed>
Parameters
$moduleName :
Tags
throws
ReflectionException
Return values
array<string|int, mixed>

getExtensionClasses()

public static getExtensionClasses() : array<string|int, mixed>
Return values
array<string|int, mixed>

pushExtensionClass()

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
throws
LogicException
throws
InvalidArgumentException
throws
ReflectionException

setEnabledClasses()

Get all annotatable classes from enabled modules

protected setEnabledClasses(string|StdClass $supportedParentClass) : mixed
Parameters
$supportedParentClass : string|StdClass
Tags
throws
ReflectionException

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
throws
ReflectionException

writeFileContent()

protected writeFileContent(string $className) : mixed
Parameters
$className : string
Tags
throws
LogicException
throws
InvalidArgumentException
throws
ReflectionException

        
On this page

Search results