Skip to content

Commit 6738e6e

Browse files
authored
Inject dependencies for services
* Inject dependencies for services * CS * Remove un-used import * Fake change to trigger CI * Do not inject application. Will try to figure out later * One more, sorry * CS * More
1 parent 0afe2d6 commit 6738e6e

File tree

18 files changed

+51
-12
lines changed

18 files changed

+51
-12
lines changed

src/administrator/components/com_weblinks/src/Extension/WeblinksComponent.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
use Joomla\CMS\Tag\TagServiceTrait;
3131
use Joomla\Component\Weblinks\Administrator\Service\HTML\AdministratorService;
3232
use Joomla\Component\Weblinks\Administrator\Service\HTML\Icon;
33+
use Joomla\Database\DatabaseInterface;
3334
use Psr\Container\ContainerInterface;
3435

3536
/**
@@ -68,10 +69,15 @@ class WeblinksComponent extends MVCComponent implements
6869
* @since 4.0.0
6970
*/
7071

71-
7272
public function boot(ContainerInterface $container)
7373
{
74-
$this->getRegistry()->register('weblinksadministrator', new AdministratorService());
74+
$this->getRegistry()->register(
75+
'weblinksadministrator',
76+
new AdministratorService(
77+
$container->get(DatabaseInterface::class)
78+
)
79+
);
80+
7581
$this->getRegistry()->register('weblinkicon', new Icon($container->get(SiteApplication::class)));
7682
}
7783

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

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
use Joomla\CMS\Language\Text;
2020
use Joomla\CMS\Layout\LayoutHelper;
2121
use Joomla\CMS\Router\Route;
22+
use Joomla\Database\DatabaseAwareTrait;
23+
use Joomla\Database\DatabaseInterface;
2224
use Joomla\Database\ParameterType;
2325

2426
/**
@@ -28,6 +30,20 @@
2830
*/
2931
class AdministratorService
3032
{
33+
use DatabaseAwareTrait;
34+
35+
/**
36+
* Service constructor
37+
*
38+
* @param DatabaseInterface $database
39+
*
40+
* @since __DEPLOY_VERSION__
41+
*/
42+
public function __construct(DatabaseInterface $database)
43+
{
44+
$this->setDatabase($database);
45+
}
46+
3147
/**
3248
* Get the associated language flags
3349
*
@@ -48,7 +64,7 @@ public function association($weblinkid)
4864
}
4965

5066
// Get the associated contact items
51-
$db = Factory::getDbo();
67+
$db = $this->getDatabase();
5268
$query = $db->getQuery(true)
5369
->select([
5470
$db->quoteName('c.id'),
@@ -66,6 +82,7 @@ public function association($weblinkid)
6682
->where($db->quoteName('c.id') . ' != :id')
6783
->bind(':id', $weblinkid, ParameterType::INTEGER);
6884
$db->setQuery($query);
85+
6986
try {
7087
$items = $db->loadObjectList('id');
7188
} catch (\RuntimeException $e) {

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

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ class Icon
3838
* @since 4.0.0
3939
*/
4040
private $application;
41+
4142
/**
42-
* Service constructor
43-
*
44-
* @param CMSApplication $application The application
45-
*
46-
* @since 4.0.0
47-
*/
43+
* Service constructor
44+
*
45+
* @param CMSApplication $application The application
46+
*
47+
* @since 4.0.0
48+
*/
4849
public function __construct(CMSApplication $application)
4950
{
5051
$this->application = $application;
@@ -61,7 +62,7 @@ public function __construct(CMSApplication $application)
6162
*
6263
* @since 4.0.0
6364
*/
64-
public static function create($category, $params, $attribs = [])
65+
public function create($category, $params, $attribs = [])
6566
{
6667
$uri = Uri::getInstance();
6768
$url = 'index.php?option=com_weblinks&task=weblink.add&return=' . base64_encode($uri) . '&w_id=0&catid=' . $category->id;
@@ -93,9 +94,9 @@ public static function create($category, $params, $attribs = [])
9394
*
9495
* @since 4.0.0
9596
*/
96-
public static function edit($weblink, $params, $attribs = [], $legacy = false)
97+
public function edit($weblink, $params, $attribs = [], $legacy = false)
9798
{
98-
$user = Factory::getApplication()->getIdentity();
99+
$user = $this->application->getIdentity();
99100
$uri = Uri::getInstance();
100101
// Ignore if in a popup window.
101102
if ($params && $params->get('popup')) {

src/administrator/components/com_weblinks/tmpl/weblink/edit.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Joomla\CMS\Language\Text;
1818
use Joomla\CMS\Layout\LayoutHelper;
1919
use Joomla\CMS\Router\Route;
20+
2021
HTMLHelper::_('behavior.formvalidator');
2122
$app = Factory::getApplication();
2223
$input = $app->input;

src/administrator/components/com_weblinks/tmpl/weblink/edit_associations.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Layout\LayoutHelper;
15+
1516
echo LayoutHelper::render('joomla.edit.associations', $this);

src/administrator/components/com_weblinks/tmpl/weblink/edit_metadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Layout\LayoutHelper;
15+
1516
echo LayoutHelper::render('joomla.edit.metadata', $this);

src/administrator/components/com_weblinks/tmpl/weblink/edit_params.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Language\Text;
15+
1516
$fieldSets = $this->form->getFieldsets('params'); ?>
1617
<?php foreach ($fieldSets as $name => $fieldSet) :
1718
?>

src/administrator/components/com_weblinks/tmpl/weblink/modal_associations.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Layout\LayoutHelper;
15+
1516
echo LayoutHelper::render('joomla.edit.associations', $this);

src/administrator/components/com_weblinks/tmpl/weblink/modal_metadata.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Layout\LayoutHelper;
15+
1516
echo LayoutHelper::render('joomla.edit.metadata', $this);

src/administrator/components/com_weblinks/tmpl/weblink/modal_params.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
\defined('_JEXEC') or die;
1313
// phpcs:enable PSR1.Files.SideEffects
1414
use Joomla\CMS\Language\Text;
15+
1516
$fieldSets = $this->form->getFieldsets('params'); ?>
1617
<?php foreach ($fieldSets as $name => $fieldSet) :
1718
?>

0 commit comments

Comments
 (0)