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