Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[4.2] Move demo tasks to service provider #38098

Merged
merged 5 commits into from
Jun 27, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions plugins/task/demotasks/demotasks.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@
<authorUrl>www.joomla.org</authorUrl>
<version>4.1</version>
<description>PLG_TASK_DEMO_TASKS_XML_DESCRIPTION</description>
<namespace path="src">Joomla\Plugin\Task\DemoTasks</namespace>
<files>
<filename plugin="demotasks">demotasks.php</filename>
<folder>language</folder>
<folder plugin="demotasks">services</folder>
<folder>src</folder>
<folder>forms</folder>
</files>
<languages>
Expand Down
51 changes: 51 additions & 0 deletions plugins/task/demotasks/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php
/**
* @package Joomla.Plugin
* @subpackage Task.DemoTasks
*
* @copyright (C) 2022 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

defined('_JEXEC') or die;

use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Plugin\Task\DemoTasks\Extension\DemoTasks;
use Joomla\Plugin\Task\SiteStatus\Extension\SiteStatus;
use Joomla\Utilities\ArrayHelper;
laoneo marked this conversation as resolved.
Show resolved Hide resolved

return new class implements ServiceProviderInterface
{
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since __DEPLOY_VERSION__
*/
public function register(Container $container)
{
$container->set(
PluginInterface::class,
function (Container $container)
{
$dispatcher = $container->get(DispatcherInterface::class);

$plugin = new DemoTasks(
$dispatcher,
(array) PluginHelper::getPlugin('task', 'demotasks')
);
$plugin->setApplication(Factory::getApplication());

return $plugin;
}
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/

namespace Joomla\Plugin\Task\DemoTasks\Extension;

// Restrict direct access
defined('_JEXEC') or die;

Expand All @@ -23,7 +25,7 @@
*
* @since 4.1.0
*/
class PlgTaskDemotasks extends CMSPlugin implements SubscriberInterface
final class DemoTasks extends CMSPlugin implements SubscriberInterface
{
use TaskPluginTrait;

Expand Down