]> git.agnieray.net Git - galette.git/blob - galette/lib/Galette/Core/PluginControllerTrait.php
2108bf125890b74288e9f23a8fc1ca5d8b2af57a
[galette.git] / galette / lib / Galette / Core / PluginControllerTrait.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Translatable objects trait
7 *
8 * PHP version 5
9 *
10 * Copyright © 2020-2023 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * @category Core
28 * @package Galette
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2020-2023 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @link http://galette.tuxfamily.org
34 * @since 2020-12-09
35 */
36
37 namespace Galette\Core;
38
39 /**
40 * Plugin controllers trait
41 *
42 * @category Entity
43 * @name PluginControllerTrait
44 * @package Galette
45 * @author Johan Cwiklinski <johan@x-tnd.be>
46 * @copyright 2020-2023 The Galette Team
47 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
48 * @link http://galette.tuxfamily.org
49 * @since 2020-12-09
50 */
51
52 trait PluginControllerTrait
53 {
54 /**
55 * Something like:
56 * #[Inject("Plugin Galette Name")]
57 * @var array
58 */
59 protected $module_info;
60
61 /**
62 * Get plugin module ID
63 *
64 * @return string
65 */
66 protected function getModuleId()
67 {
68 return $this->module_info['module_id'];
69 }
70
71 /**
72 * Get plugin module route namespace
73 * @return string
74 */
75 protected function getModuleRoute()
76 {
77 return $this->module_info['module']['route'];
78 }
79
80 /**
81 * Get plugin template name for Twig
82 *
83 * @param $name Template name
84 *
85 * @return string
86 */
87 protected function getTemplate($name): string
88 {
89 return sprintf('@%s/%s.html.twig', $this->plugins->getClassName($this->getModuleId()), $name);
90 }
91 }