1<?php
2
3/*
4 * This file is part of the league/commonmark package.
5 *
6 * (c) Colin O'Dell <colinodell@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12namespace League\CommonMark;
13
14use League\CommonMark\Block\Parser\BlockParserInterface;
15use League\CommonMark\Block\Renderer\BlockRendererInterface;
16use League\CommonMark\Delimiter\Processor\DelimiterProcessorInterface;
17use League\CommonMark\Extension\ExtensionInterface;
18use League\CommonMark\Inline\Parser\InlineParserInterface;
19use League\CommonMark\Inline\Renderer\InlineRendererInterface;
20
21/**
22 * Interface for an Environment which can be configured with config settings, parsers, processors, and renderers
23 */
24interface ConfigurableEnvironmentInterface extends EnvironmentInterface
25{
26    /**
27     * @param array<string, mixed> $config
28     *
29     * @return void
30     */
31    public function mergeConfig(array $config = []);
32
33    /**
34     * @param array<string, mixed> $config
35     *
36     * @return void
37     *
38     * @deprecated in 1.6 and will be removed in 2.0; use mergeConfig() instead
39     */
40    public function setConfig(array $config = []);
41
42    /**
43     * Registers the given extension with the Environment
44     *
45     * @param ExtensionInterface $extension
46     *
47     * @return ConfigurableEnvironmentInterface
48     */
49    public function addExtension(ExtensionInterface $extension): ConfigurableEnvironmentInterface;
50
51    /**
52     * Registers the given block parser with the Environment
53     *
54     * @param BlockParserInterface $parser   Block parser instance
55     * @param int                  $priority Priority (a higher number will be executed earlier)
56     *
57     * @return self
58     */
59    public function addBlockParser(BlockParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface;
60
61    /**
62     * Registers the given inline parser with the Environment
63     *
64     * @param InlineParserInterface $parser   Inline parser instance
65     * @param int                   $priority Priority (a higher number will be executed earlier)
66     *
67     * @return self
68     */
69    public function addInlineParser(InlineParserInterface $parser, int $priority = 0): ConfigurableEnvironmentInterface;
70
71    /**
72     * Registers the given delimiter processor with the Environment
73     *
74     * @param DelimiterProcessorInterface $processor Delimiter processors instance
75     *
76     * @return ConfigurableEnvironmentInterface
77     */
78    public function addDelimiterProcessor(DelimiterProcessorInterface $processor): ConfigurableEnvironmentInterface;
79
80    /**
81     * @param string                 $blockClass    The fully-qualified block element class name the renderer below should handle
82     * @param BlockRendererInterface $blockRenderer The renderer responsible for rendering the type of element given above
83     * @param int                    $priority      Priority (a higher number will be executed earlier)
84     *
85     * @return self
86     */
87    public function addBlockRenderer($blockClass, BlockRendererInterface $blockRenderer, int $priority = 0): ConfigurableEnvironmentInterface;
88
89    /**
90     * Registers the given inline renderer with the Environment
91     *
92     * @param string                  $inlineClass The fully-qualified inline element class name the renderer below should handle
93     * @param InlineRendererInterface $renderer    The renderer responsible for rendering the type of element given above
94     * @param int                     $priority    Priority (a higher number will be executed earlier)
95     *
96     * @return self
97     */
98    public function addInlineRenderer(string $inlineClass, InlineRendererInterface $renderer, int $priority = 0): ConfigurableEnvironmentInterface;
99
100    /**
101     * Registers the given event listener
102     *
103     * @param string   $eventClass Fully-qualified class name of the event this listener should respond to
104     * @param callable $listener   Listener to be executed
105     * @param int      $priority   Priority (a higher number will be executed earlier)
106     *
107     * @return self
108     */
109    public function addEventListener(string $eventClass, callable $listener, int $priority = 0): ConfigurableEnvironmentInterface;
110}
111