xref: /dokuwiki/inc/Parsing/ParserMode/AbstractMode.php (revision bff2c9d24314e25b31ceb53d51de76d678a0a4dc)
1<?php
2
3namespace dokuwiki\Parsing\ParserMode;
4
5use dokuwiki\Parsing\Lexer\Lexer;
6/**
7 * This class and all the subclasses below are used to reduce the effort required to register
8 * modes with the Lexer.
9 *
10 * @author Harry Fuecks <hfuecks@gmail.com>
11 */
12abstract class AbstractMode implements ModeInterface
13{
14    /** @var Lexer $Lexer will be injected on loading FIXME this should be done by setter */
15    public $Lexer;
16    protected $allowedModes = [];
17
18    /** @inheritdoc */
19    abstract public function getSort();
20
21    /** @inheritdoc */
22    public function preConnect()
23    {
24    }
25
26    /** @inheritdoc */
27    public function connectTo($mode)
28    {
29    }
30
31    /** @inheritdoc */
32    public function postConnect()
33    {
34    }
35
36    /** @inheritdoc */
37    public function accepts($mode)
38    {
39        return in_array($mode, (array) $this->allowedModes);
40    }
41}
42