MarkupManager
This class manages Twig functions, token parsers and filters.
class System\Classes\MarkupManager
Traits
| Trait | Description |
|---|---|
Singleton
|
Singleton trait. |
Constants
| Constant | Type | Value | Description |
|---|---|---|---|
EXTENSION_FILTER
|
string |
"filters"
|
string
"filters"
|
EXTENSION_FUNCTION
|
string |
"functions"
|
string
"functions"
|
EXTENSION_TOKEN_PARSER
|
string |
"tokens"
|
string
"tokens"
|
Properties
protected
$callbacks
:
array
= []
Cache of registration callbacks.
protected $items : array
Globally registered extension items
protected $pluginManager : System\Classes\PluginManager
Methods
public listExtensions (mixed $type) : array
Returns a list of the registered Twig extensions of a type.
| Property | Type | Description |
|---|---|---|
| $type | mixed |
mixed
string The Twig extension type |
public listFilters () : array
Returns a list of the registered Twig filters.
public listFunctions () : array
Returns a list of the registered Twig functions.
public listTokenParsers () : array
Returns a list of the registered Twig token parsers.
public
static
makeBaseTwigEnvironment ($loader = null, array $options = [])
: Twig\Environment
Make an instance of the base TwigEnvironment to extend further
| Property | Type | Description |
|---|---|---|
| $loader | mixed |
mixed
|
| $options | array |
array
|
public
makeTwigFilters (array $filters = [])
: array
Makes a set of Twig filters for use in a twig extension.
| Property | Type | Description |
|---|---|---|
| $filters | array |
array
Current collection |
public
makeTwigFunctions (array $functions = [])
: array
Makes a set of Twig functions for use in a twig extension.
| Property | Type | Description |
|---|---|---|
| $functions | array |
array
Current collection |
public
makeTwigTokenParsers (array $parsers = [])
: array
Makes a set of Twig token parsers for use in a twig extension.
| Property | Type | Description |
|---|---|---|
| $parsers | array |
array
Current collection |
public registerCallback (callable $callback) : void
Registers a callback function that defines simple Twig extensions.
The callback function should register menu items by calling the manager's
registerFunctions, registerFilters, registerTokenParsers function.
The manager instance is passed to the callback function as an argument. Usage:
MarkupManager::registerCallback(function ($manager) {
$manager->registerFilters([...]);
$manager->registerFunctions([...]);
$manager->registerTokenParsers([...]);
});
| Property | Type | Description |
|---|---|---|
| $callback | callable |
callable
|
public registerExtensions (string $type, array $definitions) : void
Registers the Twig extension items.
$type must be one of self::EXTENSION_TOKEN_PARSER, self::EXTENSION_FILTER, or self::EXTENSION_FUNCTION $definitions is of the format of [$extensionName => $associativeExtensionOptions]
| Property | Type | Description |
|---|---|---|
| $type | string |
string
|
| $definitions | array |
array
|
public registerFilters (array $definitions) : void
Registers a Twig Filter
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
public registerFunctions (array $definitions) : void
Registers a Twig Function
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
public registerTokenParsers (array $definitions) : void
Registers a Twig Token Parser
| Property | Type | Description |
|---|---|---|
| $definitions | array |
array
|
protected init ()
Initialize this singleton.
protected
isWildCallable (callable $callable, boolean $replaceWith = false)
: mixed
Tests if a callable type contains a wildcard, also acts as a utility to replace the wildcard with a string.
| Property | Type | Description |
|---|---|---|
| $callable | callable |
callable
|
| $replaceWith | boolean |
boolean
|
protected loadExtensions () : void
Loads all of the registered Twig extensions
inherited public __clone ()
inherited public __wakeup ()
inherited
public
static
final
forgetInstance ($container = null)
: void
Forget this singleton's instance if it exists
| Property | Type | Description |
|---|---|---|
| $container | mixed |
mixed
|
inherited
public
static
final
instance ($container = null)
: static
Create a new instance of this singleton.
| Property | Type | Description |
|---|---|---|
| $container | mixed |
mixed
|
inherited protected final __construct ()
Constructor.