BaseDirective
in package
A directive is like a function you can call or apply to a block It looks like:
.. function:: main :arg1: value :arg2: otherValue
Some block !
The directive can define variables, create special nodes or change the node that directly follows it
Table of Contents
Properties
- $aliases : array<string|int, string>
- $name : string
- $optionAttributeCache : array<string, Option>
Methods
- createNode() : Node|null
- getAliases() : array<string|int, string>
- Allow a directive to be registered under multiple names.
- getName() : string
- Get the directive name
- process() : Node|null
- This is the function called by the parser to process the directive, it can be overloaded to do anything with the document, like tweaking nodes or change the parser context
- processNode() : Node
- This can be overloaded to write a directive that just create one node for the document, which is common
- optionsToArray() : array<string, scalar|null>
- readAllOptions() : array<string, scalar|array<string|int, scalar>|null>
- readOption() : mixed
- Gets an option value from a directive based on attribute configuration.
- findOptionAttribute() : Option|null
- Finds the Option attribute for the given option name on the current class.
- getOptionValue() : scalar|array<string|int, scalar>|null
- initialize() : void
Properties
$aliases
private
array<string|int, string>
$aliases
$name
private
string
$name
$optionAttributeCache
private
array<string, Option>
$optionAttributeCache
Cache of Option attributes indexed by option name
Methods
createNode()
public
createNode(DirectiveNode $directiveNode) : Node|null
Parameters
- $directiveNode : DirectiveNode
Return values
Node|nullgetAliases()
Allow a directive to be registered under multiple names.
public
getAliases() : array<string|int, string>
Aliases can be used for directives whose name has been deprecated or allows for multiple spellings.
Return values
array<string|int, string>getName()
Get the directive name
public
getName() : string
Return values
stringprocess()
This is the function called by the parser to process the directive, it can be overloaded to do anything with the document, like tweaking nodes or change the parser context
public
process(BlockContext $blockContext, Directive $directive) : Node|null
The node that directly follows the directive is also passed to it
Parameters
- $blockContext : BlockContext
-
the current document context with the content of the directive
- $directive : Directive
-
parsed directive containing options and variable
Return values
Node|nullprocessNode()
This can be overloaded to write a directive that just create one node for the document, which is common
public
processNode(BlockContext $blockContext, Directive $directive) : Node
The arguments are the same that process
Parameters
- $blockContext : BlockContext
- $directive : Directive
Return values
NodeoptionsToArray()
protected
optionsToArray(array<string|int, DirectiveOption> $options) : array<string, scalar|null>
Parameters
- $options : array<string|int, DirectiveOption>
Return values
array<string, scalar|null>readAllOptions()
protected
final readAllOptions(Directive $directive) : array<string, scalar|array<string|int, scalar>|null>
Parameters
- $directive : Directive
Return values
array<string, scalar|array<string|int, scalar>|null>readOption()
Gets an option value from a directive based on attribute configuration.
protected
final readOption(Directive $directive, string $optionName) : mixed
Looks up the option in the directive and returns its value converted to the appropriate type based on the Option attribute defined on this directive class. If the option is not present in the directive, returns the default value from the attribute.
Parameters
- $directive : Directive
-
The directive containing the options
- $optionName : string
-
The name of the option to retrieve
Return values
mixed —The option value converted to the appropriate type, or the default value
findOptionAttribute()
Finds the Option attribute for the given option name on the current class.
private
findOptionAttribute(string $optionName) : Option|null
Parameters
- $optionName : string
-
The option name to look for
Return values
Option|null —The Option attribute if found, null otherwise
getOptionValue()
private
getOptionValue(Directive $directive, Option|null $option) : scalar|array<string|int, scalar>|null
Parameters
Return values
scalar|array<string|int, scalar>|nullinitialize()
private
initialize() : void