|
18 | 18 | use Joomla\CMS\User\CurrentUserInterface; |
19 | 19 | use Joomla\CMS\User\CurrentUserTrait; |
20 | 20 | use Joomla\CMS\Versioning\VersionableTableInterface; |
21 | | -use Joomla\Database\DatabaseDriver; |
| 21 | +use Joomla\Database\DatabaseInterface; |
22 | 22 | use Joomla\Database\ParameterType; |
23 | 23 | use Joomla\Event\DispatcherInterface; |
24 | 24 | use Joomla\Registry\Registry; |
@@ -48,12 +48,12 @@ class Category extends Nested implements VersionableTableInterface, TaggableTabl |
48 | 48 | /** |
49 | 49 | * Constructor |
50 | 50 | * |
51 | | - * @param DatabaseDriver $db Database connector object |
| 51 | + * @param DatabaseInterface $db Database connector object |
52 | 52 | * @param ?DispatcherInterface $dispatcher Event dispatcher for this table |
53 | 53 | * |
54 | 54 | * @since 1.5 |
55 | 55 | */ |
56 | | - public function __construct(DatabaseDriver $db, ?DispatcherInterface $dispatcher = null) |
| 56 | + public function __construct(DatabaseInterface $db, ?DispatcherInterface $dispatcher = null) |
57 | 57 | { |
58 | 58 | /** |
59 | 59 | * @deprecated 4.0 will be removed in 6.0 |
@@ -108,33 +108,35 @@ protected function _getAssetParentId(?Table $table = null, $id = null) |
108 | 108 | $assetId = null; |
109 | 109 |
|
110 | 110 | // This is a category under a category. |
| 111 | + $db = $this->getDatabase(); |
| 112 | + |
111 | 113 | if ($this->parent_id > 1) { |
112 | 114 | // Build the query to get the asset id for the parent category. |
113 | | - $query = $this->_db->getQuery(true) |
114 | | - ->select($this->_db->quoteName('asset_id')) |
115 | | - ->from($this->_db->quoteName('#__categories')) |
116 | | - ->where($this->_db->quoteName('id') . ' = :parentId') |
| 115 | + $query = $db->getQuery(true) |
| 116 | + ->select($db->quoteName('asset_id')) |
| 117 | + ->from($db->quoteName('#__categories')) |
| 118 | + ->where($db->quoteName('id') . ' = :parentId') |
117 | 119 | ->bind(':parentId', $this->parent_id, ParameterType::INTEGER); |
118 | 120 |
|
119 | 121 | // Get the asset id from the database. |
120 | | - $this->_db->setQuery($query); |
| 122 | + $db->setQuery($query); |
121 | 123 |
|
122 | | - if ($result = $this->_db->loadResult()) { |
| 124 | + if ($result = $db->loadResult()) { |
123 | 125 | $assetId = (int) $result; |
124 | 126 | } |
125 | 127 | } elseif ($assetId === null) { |
126 | 128 | // This is a category that needs to parent with the extension. |
127 | 129 | // Build the query to get the asset id for the parent category. |
128 | | - $query = $this->_db->getQuery(true) |
129 | | - ->select($this->_db->quoteName('id')) |
130 | | - ->from($this->_db->quoteName('#__assets')) |
131 | | - ->where($this->_db->quoteName('name') . ' = :extension') |
| 130 | + $query = $db->getQuery(true) |
| 131 | + ->select($db->quoteName('id')) |
| 132 | + ->from($db->quoteName('#__assets')) |
| 133 | + ->where($db->quoteName('name') . ' = :extension') |
132 | 134 | ->bind(':extension', $this->extension); |
133 | 135 |
|
134 | 136 | // Get the asset id from the database. |
135 | | - $this->_db->setQuery($query); |
| 137 | + $db->setQuery($query); |
136 | 138 |
|
137 | | - if ($result = $this->_db->loadResult()) { |
| 139 | + if ($result = $db->loadResult()) { |
138 | 140 | $assetId = (int) $result; |
139 | 141 | } |
140 | 142 | } |
@@ -259,7 +261,7 @@ public function store($updateNulls = true) |
259 | 261 | } |
260 | 262 |
|
261 | 263 | // Verify that the alias is unique |
262 | | - $table = new Category($this->getDbo(), $this->getDispatcher()); |
| 264 | + $table = new Category($this->getDatabase(), $this->getDispatcher()); |
263 | 265 |
|
264 | 266 | if ( |
265 | 267 | $table->load(['alias' => $this->alias, 'parent_id' => (int) $this->parent_id, 'extension' => $this->extension]) |
|
0 commit comments