diff --git a/mod_contacts_birthday.xml b/mod_contacts_birthday.xml index c67fdb9..8bb8e5f 100644 --- a/mod_contacts_birthday.xml +++ b/mod_contacts_birthday.xml @@ -7,7 +7,7 @@ GNU General Public License version 2 or later; see LICENSE.txt mediafoks@google.com https://github.com/mediafoks - 1.1.0 + 2.0.0 MOD_CONTACTS_BIRTHDAY_XML_DESCRIPTION Joomla\Module\ContactsBirthday diff --git a/services/provider.php b/services/provider.php index 0a45792..e3926ad 100644 --- a/services/provider.php +++ b/services/provider.php @@ -19,7 +19,7 @@ /** * The Ks contacts birthday module service provider. * - * @since 1.1.0 + * @since 2.0.0 */ return new class() implements ServiceProviderInterface { @@ -30,7 +30,7 @@ * * @return void * - * @since 1.1.0 + * @since 2.0.0 */ public function register(Container $container) { diff --git a/src/Dispatcher/Dispatcher.php b/src/Dispatcher/Dispatcher.php index 2320b32..b968876 100644 --- a/src/Dispatcher/Dispatcher.php +++ b/src/Dispatcher/Dispatcher.php @@ -10,12 +10,9 @@ namespace Joomla\Module\ContactsBirthday\Site\Dispatcher; -use Joomla\CMS\Application\CMSApplicationInterface; use Joomla\CMS\Dispatcher\AbstractModuleDispatcher; -use Joomla\CMS\Extension\ModuleInterface; -use Joomla\Input\Input; -use Joomla\Registry\Registry; -use Joomla\Module\ContactsBirthday\Site\Helper\ContactsBirthdayHelper; +use Joomla\CMS\Helper\HelperFactoryAwareInterface; +use Joomla\CMS\Helper\HelperFactoryAwareTrait; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -24,29 +21,27 @@ /** * Dispatcher class for mod_contacts_birthday * - * @since 1.1.0 + * @since 2.0.0 */ -class Dispatcher extends AbstractModuleDispatcher +class Dispatcher extends AbstractModuleDispatcher implements HelperFactoryAwareInterface { + use HelperFactoryAwareTrait; + /** * Returns the layout data. * * @return array * - * @since 1.1.0 + * @since 2.0.0 */ - private $moduleExtension; - - public function __construct(\stdClass $module, CMSApplicationInterface $app, Input $input) - { - parent::__construct($module, $app, $input); - } protected function getLayoutData() { $data = parent::getLayoutData(); - $helper = $this->app->bootModule('mod_contacts_birthday', 'Site')->getHelper('ContactsBirthdayHelper'); - $data['contacts'] = $helper->getContacts($data['params'], $this->getApplication()); + $data['suffixText'] = $data['params']->get('suffix_text', ''); + $data['contacts'] = $this->getHelperFactory() + ->getHelper('ContactsBirthdayHelper') + ->getContacts($data['params'], $this->getApplication()); return $data; } } diff --git a/src/Helper/ContactsBirthdayHelper.php b/src/Helper/ContactsBirthdayHelper.php index 3c07d37..69e2ee4 100644 --- a/src/Helper/ContactsBirthdayHelper.php +++ b/src/Helper/ContactsBirthdayHelper.php @@ -10,7 +10,8 @@ namespace Joomla\Module\ContactsBirthday\Site\Helper; -use Joomla\CMS\Factory; +use Joomla\Database\DatabaseAwareInterface; +use Joomla\Database\DatabaseAwareTrait; // phpcs:disable PSR1.Files.SideEffects \defined('_JEXEC') or die; @@ -19,13 +20,15 @@ /** * Helper for mod_contacts_birthday * - * @since 1.1.0 + * @since 2.0.0 */ -class ContactsBirthdayHelper +class ContactsBirthdayHelper implements DatabaseAwareInterface { + use DatabaseAwareTrait; + public function getContacts($params): array { - $db = Factory::getContainer()->get('DatabaseDriver'); + $db = $this->getDatabase(); $catId = join(',', $params->get('catid')); diff --git a/tmpl/default.php b/tmpl/default.php index 1b495ea..d8a8ea4 100644 --- a/tmpl/default.php +++ b/tmpl/default.php @@ -18,7 +18,6 @@ $today = date("m-d"); //Текущая дата $contacts_name = []; //Массив с именами контактов -$suffix_text = $params->get('suffix_text'); // Дополнительный текст foreach ($contacts as $key => $contact) { $name = $contact->name; //Имя контакта @@ -32,6 +31,6 @@ - 1 ? Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT') : Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT'), ' ' . Text::_('MOD_CONTACTS_BIRTHDAY_EVENT_TXT') . ' ' . $suffix_text ?: ''; ?> + 1 ? Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_PLURAL_TXT') : Text::_('MOD_CONTACTS_BIRTHDAY_SUFFIX_SINGULAR_TXT'), ' ' . Text::_('MOD_CONTACTS_BIRTHDAY_EVENT_TXT') . ' ' . $suffixText ?: ''; ?> \ No newline at end of file diff --git a/update.xml b/update.xml index 22e647a..1b49c00 100644 --- a/update.xml +++ b/update.xml @@ -5,9 +5,9 @@ mod_contacts_birthday module site - 1.1.0 + 2.0.0 - https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v1.1.0.zip + https://github.com/mediafoks/mod_contacts_birthday/archive/refs/tags/v2.0.0.zip stable