Environment
in package
implements
EnvironmentInterface, EnvironmentBuilderInterface, ListenerProviderInterface
Table of Contents
Interfaces
- EnvironmentInterface
- Interface for a service which provides a readable configuration object
- EnvironmentBuilderInterface
- Interface for building the Environment with any extensions, parsers, listeners, etc. that it may need
- ListenerProviderInterface
- Mapper from an event to the listeners that are applicable to that event.
Properties
- $blockStartParsers : PrioritizedList<string|int, BlockStartParserInterface>
- $config : Configuration
- $delimiterProcessors : DelimiterProcessorCollection
- $eventDispatcher : EventDispatcherInterface|null
- $extensions : array<string|int, ExtensionInterface>
- $extensionsInitialized : bool
- $inlineParsers : PrioritizedList<string|int, InlineParserInterface>
- $listenerData : PrioritizedList<string|int, ListenerData>
- $renderersByClass : array<string, PrioritizedList<string|int, NodeRendererInterface>>
- $slugNormalizer : TextNormalizerInterface|null
- $uninitializedExtensions : array<string|int, ExtensionInterface>
Methods
- __construct() : mixed
- addBlockStartParser() : $this
- Registers the given block start parser with the Environment
- addDelimiterProcessor() : EnvironmentBuilderInterface
- Registers the given delimiter processor with the Environment
- addEventListener() : $this
- Registers the given event listener
- addExtension() : $this
- Add a single extension
- addInlineParser() : $this
- Registers the given inline parser with the Environment
- addRenderer() : $this
- Registers the given node renderer with the Environment
- createCommonMarkEnvironment() : Environment
- createDefaultConfiguration() : Configuration
- createGFMEnvironment() : Environment
- dispatch() : object
- Provide all relevant listeners with an event to process.
- getBlockStartParsers() : iterable<string|int, BlockStartParserInterface>
- getConfiguration() : ConfigurationInterface
- getDelimiterProcessors() : DelimiterProcessorCollection
- getExtensions() : array<string|int, ExtensionInterface>
- Get all registered extensions
- getInlineParsers() : iterable<string|int, InlineParserInterface>
- getListenersForEvent() : iterable<string|int, callable>
- getRenderersForClass() : iterable<string|int, NodeRendererInterface>
- getSlugNormalizer() : TextNormalizerInterface
- mergeConfig() : void
- setEventDispatcher() : void
- assertUninitialized() : void
- initializeExtensions() : void
- injectEnvironmentAndConfigurationIfNeeded() : void
Properties
$blockStartParsers
private
PrioritizedList<string|int, BlockStartParserInterface>
$blockStartParsers
Tags
$config
private
Configuration
$config
Tags
$delimiterProcessors
private
DelimiterProcessorCollection
$delimiterProcessors
Tags
$eventDispatcher
private
EventDispatcherInterface|null
$eventDispatcher
= null
$extensions
private
array<string|int, ExtensionInterface>
$extensions
= []
Tags
$extensionsInitialized
private
bool
$extensionsInitialized
= false
Tags
$inlineParsers
private
PrioritizedList<string|int, InlineParserInterface>
$inlineParsers
Tags
$listenerData
private
PrioritizedList<string|int, ListenerData>
$listenerData
Tags
$renderersByClass
private
array<string, PrioritizedList<string|int, NodeRendererInterface>>
$renderersByClass
= []
Tags
$slugNormalizer
private
TextNormalizerInterface|null
$slugNormalizer
= null
$uninitializedExtensions
private
array<string|int, ExtensionInterface>
$uninitializedExtensions
= []
Tags
Methods
__construct()
public
__construct([array<string, mixed> $config = [] ]) : mixed
Parameters
- $config : array<string, mixed> = []
addBlockStartParser()
Registers the given block start parser with the Environment
public
addBlockStartParser(BlockStartParserInterface $parser[, int $priority = 0 ]) : $this
Parameters
- $parser : BlockStartParserInterface
-
Block parser instance
- $priority : int = 0
-
Priority (a higher number will be executed earlier)
Return values
$thisaddDelimiterProcessor()
Registers the given delimiter processor with the Environment
public
addDelimiterProcessor(DelimiterProcessorInterface $processor) : EnvironmentBuilderInterface
Parameters
- $processor : DelimiterProcessorInterface
-
Delimiter processors instance
Return values
EnvironmentBuilderInterfaceaddEventListener()
Registers the given event listener
public
addEventListener(string $eventClass, callable $listener[, int $priority = 0 ]) : $this
Parameters
- $eventClass : string
-
Fully-qualified class name of the event this listener should respond to
- $listener : callable
-
Listener to be executed
- $priority : int = 0
-
Priority (a higher number will be executed earlier)
Return values
$thisaddExtension()
Add a single extension
public
addExtension(ExtensionInterface $extension) : $this
Parameters
- $extension : ExtensionInterface
Return values
$thisaddInlineParser()
Registers the given inline parser with the Environment
public
addInlineParser(InlineParserInterface $parser[, int $priority = 0 ]) : $this
Parameters
- $parser : InlineParserInterface
-
Inline parser instance
- $priority : int = 0
-
Priority (a higher number will be executed earlier)
Return values
$thisaddRenderer()
Registers the given node renderer with the Environment
public
addRenderer(string $nodeClass, NodeRendererInterface $renderer[, int $priority = 0 ]) : $this
Parameters
- $nodeClass : string
-
The fully-qualified node element class name the renderer below should handle
- $renderer : NodeRendererInterface
-
The renderer responsible for rendering the type of element given above
- $priority : int = 0
-
Priority (a higher number will be executed earlier)
Return values
$thiscreateCommonMarkEnvironment()
public
static createCommonMarkEnvironment([array<string, mixed> $config = [] ]) : Environment
Instantiate the environment and add the extension yourself
Parameters
- $config : array<string, mixed> = []
Return values
EnvironmentcreateDefaultConfiguration()
public
static createDefaultConfiguration() : Configuration
Return values
ConfigurationcreateGFMEnvironment()
public
static createGFMEnvironment([array<string, mixed> $config = [] ]) : Environment
Instantiate the environment and add the extension yourself
Parameters
- $config : array<string, mixed> = []
Return values
Environmentdispatch()
Provide all relevant listeners with an event to process.
public
dispatch(object $event) : object
Parameters
- $event : object
-
The object to process.
Return values
object —The Event that was passed, now modified by listeners.
getBlockStartParsers()
public
getBlockStartParsers() : iterable<string|int, BlockStartParserInterface>
Return values
iterable<string|int, BlockStartParserInterface>getConfiguration()
public
getConfiguration() : ConfigurationInterface
Return values
ConfigurationInterfacegetDelimiterProcessors()
public
getDelimiterProcessors() : DelimiterProcessorCollection
Return values
DelimiterProcessorCollectiongetExtensions()
Get all registered extensions
public
getExtensions() : array<string|int, ExtensionInterface>
Return values
array<string|int, ExtensionInterface>getInlineParsers()
public
getInlineParsers() : iterable<string|int, InlineParserInterface>
Return values
iterable<string|int, InlineParserInterface>getListenersForEvent()
public
getListenersForEvent(object $event) : iterable<string|int, callable>
Parameters
- $event : object
-
An event for which to return the relevant listeners.
Return values
iterable<string|int, callable>getRenderersForClass()
public
getRenderersForClass(string $nodeClass) : iterable<string|int, NodeRendererInterface>
Parameters
- $nodeClass : string
Return values
iterable<string|int, NodeRendererInterface>getSlugNormalizer()
public
getSlugNormalizer() : TextNormalizerInterface
Return values
TextNormalizerInterfacemergeConfig()
public
mergeConfig(array<string, mixed> $config) : void
Environment::mergeConfig() is deprecated since league/commonmark v2.0 and will be removed in v3.0. Configuration should be set when instantiating the environment instead.
Parameters
- $config : array<string, mixed>
setEventDispatcher()
public
setEventDispatcher(EventDispatcherInterface $dispatcher) : void
Parameters
- $dispatcher : EventDispatcherInterface
assertUninitialized()
private
assertUninitialized(string $message) : void
Parameters
- $message : string
Tags
initializeExtensions()
private
initializeExtensions() : void
injectEnvironmentAndConfigurationIfNeeded()
private
injectEnvironmentAndConfigurationIfNeeded(object $object) : void
Parameters
- $object : object