Documentation

Environment
in package
implements EnvironmentInterface, EnvironmentBuilderInterface, ListenerProviderInterface

FinalYes

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

$extensionsInitialized

private bool $extensionsInitialized = false
Tags
psalm-readonly-allow-private-mutation

$listenerData

private PrioritizedList<string|int, ListenerData> $listenerData
Tags
psalm-readonly-allow-private-mutation

$renderersByClass

private array<string, PrioritizedList<string|int, NodeRendererInterface>> $renderersByClass = []
Tags
psalm-readonly-allow-private-mutation

$uninitializedExtensions

private array<string|int, ExtensionInterface> $uninitializedExtensions = []
Tags
psalm-readonly-allow-private-mutation

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
$this

addEventListener()

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
$this

addInlineParser()

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
$this

addRenderer()

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
$this

createCommonMarkEnvironment()

public static createCommonMarkEnvironment([array<string, mixed> $config = [] ]) : Environment

Instantiate the environment and add the extension yourself

Parameters
$config : array<string, mixed> = []
Return values
Environment

createGFMEnvironment()

public static createGFMEnvironment([array<string, mixed> $config = [] ]) : Environment

Instantiate the environment and add the extension yourself

Parameters
$config : array<string, mixed> = []
Return values
Environment

dispatch()

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.

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>

mergeConfig()

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>

initializeExtensions()

private initializeExtensions() : void

injectEnvironmentAndConfigurationIfNeeded()

private injectEnvironmentAndConfigurationIfNeeded(object $object) : void
Parameters
$object : object

        
On this page

Search results