1<?php
2/*
3 * Yurii's Gantt Plugin
4 *
5 * Copyright (C) 2020 Yurii K.
6 *
7 * This program is free software: you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program.  If not, see http://www.gnu.org/licenses
19 */
20
21namespace dokuwiki\plugin\yuriigantt\src\Driver\Embedded;
22
23use dokuwiki\Extension\SyntaxPlugin;
24use dokuwiki\plugin\yuriigantt\src\Driver\Embedded;
25
26/**
27 * Simplified renderer version for internal usage only!
28 */
29final class Renderer extends \Doku_Renderer // NOTE: remove extend when PHP 5.6-7.1 support is dropped
30{
31    public $doc = '';
32
33    /**
34     * Render data without change
35     *
36     * @param string $data
37     */
38    public function raw($data)
39    {
40        $this->doc .= $data;
41    }
42
43
44    /**
45     * Returns the format produced by this renderer.
46     *
47     * Has to be overidden by sub classes
48     *
49     * @return string
50     */
51    public function getFormat()
52    {
53        return Embedded::MODE;
54    }
55
56
57    /**
58     * Handle plugin rendering
59     *
60     * Most likely this needs NOT to be overwritten by sub classes
61     *
62     * @param string $name Plugin name
63     * @param mixed $data custom data set by handler
64     * @param string $state matched state if any
65     * @param string $match raw matched syntax
66     */
67    public function plugin($name, $data, $state = '', $match = '')
68    {
69        if ($plugin = plugin_load('syntax', $name)) {
70            /** @var SyntaxPlugin $plugin */
71            $plugin->render($this->getFormat(), $this, $data);
72        }
73    }
74}
75