mirror of
https://github.com/joomla-extensions/weblinks.git
synced 2025-01-27 22:38:28 +00:00
Merge pull request #518 from joomdonation/convert_weblink_editor_xtd_plugin
Convert weblink editor-xtd plugin to service provider
This commit is contained in:
commit
270f22954b
@ -51,6 +51,7 @@ class Com_WeblinksInstallerScript
|
||||
'/modules/mod_weblinks/mod_weblinks.php',
|
||||
'/plugins/search/weblinks/weblinks.php',
|
||||
'/plugins/finder/weblinks/weblinks.php',
|
||||
'/plugins/editors-xtd/weblink/weblink.php',
|
||||
];
|
||||
|
||||
$folders = [
|
||||
|
47
src/plugins/editors-xtd/services/provider.php
Normal file
47
src/plugins/editors-xtd/services/provider.php
Normal file
@ -0,0 +1,47 @@
|
||||
<?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) {
|
||||
$app = Factory::getApplication();
|
||||
$dispatcher = $container->get(DispatcherInterface::class);
|
||||
|
||||
return new Weblink(
|
||||
$dispatcher,
|
||||
(array) PluginHelper::getPlugin('editors-xtd', 'weblink'),
|
||||
$app
|
||||
);
|
||||
}
|
||||
);
|
||||
}
|
||||
};
|
@ -7,28 +7,26 @@
|
||||
* @license GNU General Public License version 2 or later; see LICENSE.txt
|
||||
*/
|
||||
|
||||
namespace Joomla\Plugin\EditorsXtd\Weblink\Extension;
|
||||
|
||||
defined('_JEXEC') or die;
|
||||
|
||||
use Joomla\CMS\Application\CMSApplicationInterface;
|
||||
use Joomla\CMS\Language\Text;
|
||||
use Joomla\CMS\Object\CMSObject;
|
||||
use Joomla\CMS\Plugin\CMSPlugin;
|
||||
use Joomla\CMS\Session\Session;
|
||||
use Joomla\Database\DatabaseAwareTrait;
|
||||
use Joomla\Database\DatabaseInterface;
|
||||
use Joomla\Event\DispatcherInterface;
|
||||
|
||||
/**
|
||||
* Editor Web Link button
|
||||
*
|
||||
* @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.
|
||||
*
|
||||
@ -37,18 +35,32 @@ class PlgButtonWeblink extends CMSPlugin
|
||||
*/
|
||||
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
|
||||
*
|
||||
* @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__
|
||||
*/
|
||||
public function onDisplay($name)
|
||||
{
|
||||
$user = $this->app->getIdentity();
|
||||
$user = $this->getApplication()->getIdentity();
|
||||
|
||||
if ($user->authorise('core.create', 'com_weblinks')
|
||||
|| $user->authorise('core.edit', 'com_weblinks')
|
@ -9,6 +9,7 @@
|
||||
<authorUrl>www.joomla.org</authorUrl>
|
||||
<version>##VERSION##</version>
|
||||
<description>PLG_EDITORS-XTD_WEBLINK_XML_DESCRIPTION</description>
|
||||
<namespace path="src">Joomla\Plugin\EditorsXtd\Weblink</namespace>
|
||||
<files>
|
||||
##FILES##
|
||||
</files>
|
||||
|
Loading…
x
Reference in New Issue
Block a user