Skip to content

Commit e9f577e

Browse files
authored
Replace Factory::getDbo() by Factory::getContainer()->get(DatabaseInterface::class) (#569)
1 parent 738444b commit e9f577e

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

src/administrator/components/com_weblinks/script.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use Joomla\CMS\Installer\InstallerAdapter;
1717
use Joomla\CMS\Language\Text;
1818
use Joomla\CMS\Table\Category;
19+
use Joomla\Database\DatabaseInterface;
1920
use Joomla\Filesystem\File;
2021
use Joomla\Filesystem\Folder;
2122

@@ -86,7 +87,7 @@ public function preflight($type, $parent)
8687
public function install($parent)
8788
{
8889
// Initialize a new category
89-
$category = new Category(Factory::getDbo());
90+
$category = new Category(Factory::getContainer()->get(DatabaseInterface::class));
9091

9192
// Check if the Uncategorised category exists before adding it
9293
if (!$category->load(['extension' => 'com_weblinks', 'title' => 'Uncategorised'])) {
@@ -141,7 +142,7 @@ public function install($parent)
141142
public function postflight($type, $parent)
142143
{
143144
// Only execute database changes on MySQL databases
144-
$dbName = Factory::getDbo()->name;
145+
$dbName = Factory::getContainer()->get(DatabaseInterface::class)->name;
145146

146147
if (strpos($dbName, 'mysql') !== false) {
147148
// Add Missing Table Columns if needed
@@ -165,7 +166,7 @@ public function postflight($type, $parent)
165166
private function insertMissingUcmRecords()
166167
{
167168
// Insert the rows in the #__content_types table if they don't exist already
168-
$db = Factory::getDbo();
169+
$db = Factory::getContainer()->get(DatabaseInterface::class);
169170

170171
// Get the type ID for a Weblink
171172
$query = $db->getQuery(true);
@@ -287,7 +288,7 @@ private function dropColumnsIfNeeded()
287288
'approved',
288289
];
289290

290-
$db = Factory::getDbo();
291+
$db = Factory::getContainer()->get(DatabaseInterface::class);
291292
$table = $db->getTableColumns('#__weblinks');
292293

293294
$columns = array_intersect($oldColumns, array_keys($table));
@@ -308,7 +309,7 @@ private function dropColumnsIfNeeded()
308309
*/
309310
private function addColumnsIfNeeded()
310311
{
311-
$db = Factory::getDbo();
312+
$db = Factory::getContainer()->get(DatabaseInterface::class);
312313
$table = $db->getTableColumns('#__weblinks');
313314

314315
if (!\array_key_exists('version', $table)) {

src/administrator/components/com_weblinks/src/Helper/AssociationsHelper.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
use Joomla\CMS\Table\Table;
2121
use Joomla\Component\Weblinks\Administrator\Table\WeblinkTable;
2222
use Joomla\Component\Weblinks\Site\Helper\AssociationHelper;
23+
use Joomla\Database\DatabaseInterface;
2324

2425
/**
2526
* Content associations helper.
@@ -114,11 +115,11 @@ public function getItem($typeName, $id)
114115
$table = null;
115116
switch ($typeName) {
116117
case 'weblink':
117-
$table = new WeblinkTable(Factory::getDbo());
118+
$table = new WeblinkTable(Factory::getContainer()->get(DatabaseInterface::class));
118119

119120
break;
120121
case 'category':
121-
$table = new Category(Factory::getDbo());
122+
$table = new Category(Factory::getContainer()->get(DatabaseInterface::class));
122123

123124
break;
124125
}

src/administrator/components/com_weblinks/src/Service/HTML/Icon.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,7 @@ public function edit($weblink, $params, $attribs = [], $legacy = false)
138138

139139
if (
140140
($weblink->publish_up !== null && strtotime($weblink->publish_up) > $nowDate)
141-
|| ($weblink->publish_down !== null && strtotime($weblink->publish_down) < $nowDate
142-
&& $weblink->publish_down !== Factory::getDbo()->getNullDate())
141+
|| ($weblink->publish_down !== null && strtotime($weblink->publish_down) < $nowDate)
143142
) {
144143
$icon = 'eye-slash';
145144
}

src/administrator/components/com_weblinks/src/View/Weblink/HtmlView.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,8 +99,7 @@ public function display($tpl = null)
9999
*/
100100
protected function addToolbar()
101101
{
102-
$app = Factory::getApplication();
103-
$app->getInput()->set('hidemainmenu', true);
102+
Factory::getApplication()->getInput()->set('hidemainmenu', true);
104103

105104
$user = $this->getCurrentUser();
106105
$isNew = ($this->item->id == 0);

0 commit comments

Comments
 (0)