|
13 | 13 | use Joomla\CMS\Application\CMSApplication; |
14 | 14 | use Joomla\CMS\Component\ComponentHelper; |
15 | 15 | use Joomla\CMS\Event\Menu\PreprocessMenuItemsEvent; |
| 16 | +use Joomla\CMS\Factory; |
16 | 17 | use Joomla\CMS\Language\Associations; |
17 | 18 | use Joomla\CMS\Language\Text; |
18 | 19 | use Joomla\CMS\Menu\AdministratorMenuItem; |
19 | 20 | use Joomla\CMS\Uri\Uri; |
20 | 21 | use Joomla\Component\Menus\Administrator\Helper\MenusHelper; |
| 22 | +use Joomla\Database\DatabaseAwareInterface; |
| 23 | +use Joomla\Database\DatabaseAwareTrait; |
| 24 | +use Joomla\Database\DatabaseInterface; |
21 | 25 | use Joomla\Registry\Registry; |
22 | 26 | use Joomla\Utilities\ArrayHelper; |
23 | 27 |
|
|
30 | 34 | * |
31 | 35 | * @since 1.5 |
32 | 36 | */ |
33 | | -class CssMenu |
| 37 | +class CssMenu implements DatabaseAwareInterface |
34 | 38 | { |
| 39 | + use DatabaseAwareTrait; |
| 40 | + |
35 | 41 | /** |
36 | 42 | * The root of the menu |
37 | 43 | * |
@@ -89,12 +95,24 @@ class CssMenu |
89 | 95 | /** |
90 | 96 | * CssMenu constructor. |
91 | 97 | * |
92 | | - * @param CMSApplication $application The application |
| 98 | + * @param CMSApplication $application The application |
| 99 | + * @param ?DatabaseInterface $db The database |
93 | 100 | * |
94 | 101 | * @since 4.0.0 |
95 | 102 | */ |
96 | | - public function __construct(CMSApplication $application) |
| 103 | + public function __construct(CMSApplication $application, ?DatabaseInterface $db = null) |
97 | 104 | { |
| 105 | + if ($db === null) { |
| 106 | + @trigger_error( |
| 107 | + __CLASS__ . ': The $db parameter must be set for the constructor.', |
| 108 | + \E_USER_DEPRECATED |
| 109 | + ); |
| 110 | + |
| 111 | + $db = Factory::getContainer()->get(DatabaseInterface::class); |
| 112 | + } |
| 113 | + |
| 114 | + $this->setDatabase($db); |
| 115 | + |
98 | 116 | $this->application = $application; |
99 | 117 | $this->root = new AdministratorMenuItem(); |
100 | 118 | } |
@@ -230,7 +248,7 @@ protected function check($node, Registry $params) |
230 | 248 | $uri = clone Uri::getInstance(); |
231 | 249 | $uri->setVar('recover_menu', 1); |
232 | 250 |
|
233 | | - $table = $this->application->bootComponent('com_menu')->getMVCFactory()->createTable('MenuType'); |
| 251 | + $table = new \Joomla\CMS\Table\MenuType($this->getDatabase()); |
234 | 252 | $menutype = $params->get('menutype'); |
235 | 253 |
|
236 | 254 | $table->load(['menutype' => $menutype]); |
|
0 commit comments