mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2024-09-28 04:59:04 +00:00
Convert weblink editor-xtd plugin to service provider structure
This commit is contained in:
parent
8d928181e9
commit
11a50bf1cc
46
src/plugins/editors-xtd/services/provider.php
Normal file
46
src/plugins/editors-xtd/services/provider.php
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @package Joomla.Plugin
|
||||||
|
* @subpackage Editors-xtd.article
|
||||||
|
*
|
||||||
|
* @copyright (C) 2023 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\EditorsXtd\Weblink\Extension\Weblink;
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
return new Weblink(
|
||||||
|
$dispatcher,
|
||||||
|
(array) PluginHelper::getPlugin('editors-xtd', 'weblink'),
|
||||||
|
Factory::getApplication()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
};
|
@ -7,28 +7,26 @@
|
|||||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
namespace Joomla\Plugin\EditorsXtd\Weblink\Extension;
|
||||||
|
|
||||||
defined('_JEXEC') or die;
|
defined('_JEXEC') or die;
|
||||||
|
|
||||||
|
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||||
use Joomla\CMS\Language\Text;
|
use Joomla\CMS\Language\Text;
|
||||||
use Joomla\CMS\Object\CMSObject;
|
use Joomla\CMS\Object\CMSObject;
|
||||||
use Joomla\CMS\Plugin\CMSPlugin;
|
use Joomla\CMS\Plugin\CMSPlugin;
|
||||||
use Joomla\CMS\Session\Session;
|
use Joomla\CMS\Session\Session;
|
||||||
|
use Joomla\Database\DatabaseAwareTrait;
|
||||||
|
use Joomla\Database\DatabaseInterface;
|
||||||
|
use Joomla\Event\DispatcherInterface;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Editor Web Link button
|
* Editor Web Link button
|
||||||
*
|
*
|
||||||
* @since __DEPLOY_VERSION__
|
* @since __DEPLOY_VERSION__
|
||||||
*/
|
*/
|
||||||
class PlgButtonWeblink extends CMSPlugin
|
final class Weblink extends CMSPlugin
|
||||||
{
|
{
|
||||||
/**
|
|
||||||
* Application object
|
|
||||||
*
|
|
||||||
* @var \Joomla\CMS\Application\CMSApplicationInterface
|
|
||||||
* @since 4.0.0
|
|
||||||
*/
|
|
||||||
protected $app;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Load the language file on instantiation.
|
* Load the language file on instantiation.
|
||||||
*
|
*
|
||||||
@ -37,18 +35,32 @@ class PlgButtonWeblink extends CMSPlugin
|
|||||||
*/
|
*/
|
||||||
protected $autoloadLanguage = true;
|
protected $autoloadLanguage = true;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructor
|
||||||
|
*
|
||||||
|
* @param DispatcherInterface $dispatcher
|
||||||
|
* @param array $config
|
||||||
|
* @param DatabaseInterface $database
|
||||||
|
*/
|
||||||
|
public function __construct(DispatcherInterface $dispatcher, array $config, CMSApplicationInterface $application)
|
||||||
|
{
|
||||||
|
parent::__construct($dispatcher, $config);
|
||||||
|
|
||||||
|
$this->setApplication($application);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Display the button
|
* Display the button
|
||||||
*
|
*
|
||||||
* @param string $name The name of the button to add
|
* @param string $name The name of the button to add
|
||||||
*
|
*
|
||||||
* @return JObject The button options as JObject
|
* @return CMSObject The button options as JObject
|
||||||
*
|
*
|
||||||
* @since __DEPLOY_VERSION__
|
* @since __DEPLOY_VERSION__
|
||||||
*/
|
*/
|
||||||
public function onDisplay($name)
|
public function onDisplay($name)
|
||||||
{
|
{
|
||||||
$user = $this->app->getIdentity();
|
$user = $this->getApplication()->getIdentity();
|
||||||
|
|
||||||
if ($user->authorise('core.create', 'com_weblinks')
|
if ($user->authorise('core.create', 'com_weblinks')
|
||||||
|| $user->authorise('core.edit', 'com_weblinks')
|
|| $user->authorise('core.edit', 'com_weblinks')
|
@ -9,6 +9,7 @@
|
|||||||
<authorUrl>www.joomla.org</authorUrl>
|
<authorUrl>www.joomla.org</authorUrl>
|
||||||
<version>##VERSION##</version>
|
<version>##VERSION##</version>
|
||||||
<description>PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION</description>
|
<description>PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION</description>
|
||||||
|
<namespace path="src">Joomla\Plugin\EditorsXtd\Weblink</namespace>
|
||||||
<files>
|
<files>
|
||||||
##FILES##
|
##FILES##
|
||||||
</files>
|
</files>
|
||||||
|
Loading…
Reference in New Issue
Block a user