Skip to content

Commit

Permalink
Merge branch '4.2-dev' into j4/users/login-model
Browse files Browse the repository at this point in the history
  • Loading branch information
laoneo committed Apr 24, 2022
2 parents 520e752 + 2b11b08 commit 6815238
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Joomla\CMS\Tag\TagServiceInterface;
use Joomla\CMS\Tag\TagServiceTrait;
use Joomla\Component\Banners\Administrator\Service\Html\Banner;
use Joomla\Database\DatabaseInterface;
use Psr\Container\ContainerInterface;

/**
Expand Down Expand Up @@ -53,7 +54,10 @@ class BannersComponent extends MVCComponent implements BootableExtensionInterfac
*/
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('banner', new Banner);
$banner = new Banner;
$banner->setDatabase($container->get(DatabaseInterface::class));

$this->getRegistry()->register('banner', $banner);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;
use Joomla\Database\DatabaseAwareTrait;

/**
* Banner HTML class.
Expand All @@ -22,6 +23,8 @@
*/
class Banner
{
use DatabaseAwareTrait;

/**
* Display a batch widget for the client selector.
*
Expand Down Expand Up @@ -56,7 +59,7 @@ public function clients()
*/
public function clientlist()
{
$db = Factory::getDbo();
$db = $this->getDatabase();
$query = $db->getQuery(true)
->select(
[
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

\defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Application\SiteApplication;
use Joomla\CMS\Association\AssociationServiceInterface;
use Joomla\CMS\Association\AssociationServiceTrait;
use Joomla\CMS\Categories\CategoryServiceInterface;
Expand All @@ -27,6 +26,7 @@
use Joomla\CMS\Language\Text;
use Joomla\CMS\Tag\TagServiceInterface;
use Joomla\CMS\Tag\TagServiceTrait;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\Component\Contact\Administrator\Service\HTML\AdministratorService;
use Joomla\Component\Contact\Administrator\Service\HTML\Icon;
use Psr\Container\ContainerInterface;
Expand Down Expand Up @@ -64,7 +64,7 @@ class ContactComponent extends MVCComponent implements
public function boot(ContainerInterface $container)
{
$this->getRegistry()->register('contactadministrator', new AdministratorService);
$this->getRegistry()->register('contacticon', new Icon($container->get(SiteApplication::class)));
$this->getRegistry()->register('contacticon', new Icon($container->get(UserFactoryInterface::class)));
}

/**
Expand Down
24 changes: 12 additions & 12 deletions administrator/components/com_contact/src/Service/HTML/Icon.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Joomla\CMS\Layout\LayoutHelper;
use Joomla\CMS\Router\Route;
use Joomla\CMS\Uri\Uri;
use Joomla\CMS\User\UserFactoryInterface;
use Joomla\Component\Contact\Site\Helper\RouteHelper;
use Joomla\Registry\Registry;

Expand All @@ -29,24 +30,24 @@
class Icon
{
/**
* The application
* The user factory
*
* @var CMSApplication
* @var UserFactoryInterface
*
* @since 4.0.0
* @since __DEPLOY_VERSION__
*/
private $application;
private $userFactory;

/**
* Service constructor
*
* @param CMSApplication $application The application
* @param UserFactoryInterface $userFactory The userFactory
*
* @since 4.0.0
*/
public function __construct(CMSApplication $application)
public function __construct(UserFactoryInterface $userFactory)
{
$this->application = $application;
$this->userFactory = $userFactory;
}

/**
Expand All @@ -60,7 +61,7 @@ public function __construct(CMSApplication $application)
*
* @since 4.0.0
*/
public static function create($category, $params, $attribs = array())
public function create($category, $params, $attribs = array())
{
$uri = Uri::getInstance();

Expand Down Expand Up @@ -105,7 +106,7 @@ public static function create($category, $params, $attribs = array())
*
* @since 4.0.0
*/
public static function edit($contact, $params, $attribs = array(), $legacy = false)
public function edit($contact, $params, $attribs = array(), $legacy = false)
{
$user = Factory::getUser();
$uri = Uri::getInstance();
Expand All @@ -128,7 +129,7 @@ public static function edit($contact, $params, $attribs = array(), $legacy = fal
&& !is_null($contact->checked_out)
&& $contact->checked_out !== $user->get('id'))
{
$checkoutUser = Factory::getUser($contact->checked_out);
$checkoutUser = $this->userFactory->loadUserById($contact->checked_out);
$date = HTMLHelper::_('date', $contact->checked_out_time);
$tooltip = Text::sprintf('COM_CONTACT_CHECKED_OUT_BY', $checkoutUser->name)
. ' <br> ' . $date;
Expand Down Expand Up @@ -157,8 +158,7 @@ public static function edit($contact, $params, $attribs = array(), $legacy = fal
$icon = $contact->published ? 'edit' : 'eye-slash';

if (($contact->publish_up !== null && strtotime($contact->publish_up) > $nowDate)
|| ($contact->publish_down !== null && strtotime($contact->publish_down) < $nowDate
&& $contact->publish_down !== Factory::getDbo()->getNullDate()))
|| ($contact->publish_down !== null && strtotime($contact->publish_down) < $nowDate))
{
$icon = 'eye-slash';
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,8 @@ class HtmlView extends BaseHtmlView
*
* @var DatabaseDriver
* @since 3.6.3
*
* @deprecated 5.0 Will be removed without replacement
*/
protected $db;

Expand Down
2 changes: 2 additions & 0 deletions components/com_content/src/View/Featured/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ class HtmlView extends BaseHtmlView
* @var \Joomla\Database\DatabaseDriver
*
* @since 3.6.3
*
* @deprecated 5.0 Will be removed without replacement
*/
protected $db;

Expand Down
2 changes: 2 additions & 0 deletions components/com_users/src/View/Profile/HtmlView.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class HtmlView extends BaseHtmlView
*
* @var DatabaseDriver
* @since 3.6.3
*
* @deprecated 5.0 Will be removed without replacement
*/
protected $db;

Expand Down

0 comments on commit 6815238

Please sign in to comment.