-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 8a070c5
Showing
9 changed files
with
203 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
root = true | ||
|
||
[*] | ||
charset = utf-8 | ||
indent_size = 4 | ||
indent_style = tab | ||
end_of_line = lf | ||
insert_final_newline = true | ||
trim_trailing_whitespace = true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Joomla system plugin for JEA | ||
|
||
This plugin adds commands to the Joomla! 4 CLI (cli/joomla.php) | ||
|
||
## Commands | ||
|
||
- `jea:gateways:export` Run JEA gateways export jobs | ||
- `jea:gateways:import` Run JEA gateways import jobs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?php | ||
|
||
/** | ||
* @package Joomla.Plugin | ||
* @subpackage System.Jea | ||
* | ||
* @copyright (C) 2006 Open Source Matters, Inc. <https://www.joomla.org> | ||
* @license GNU General Public License version 2 or later; see LICENSE.txt | ||
*/ | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\CMS\Plugin\CMSPlugin; | ||
use Joomla\Event\SubscriberInterface; | ||
use Joomla\Application\ApplicationEvents; | ||
use Joomla\CMS\Console\Loader\WritableLoaderInterface; | ||
use Joomla\Plugin\System\Jea\Console\GatewaysExportCommand; | ||
use Joomla\Plugin\System\Jea\Console\GatewaysImportCommand; | ||
|
||
defined('_JEXEC') or die; | ||
|
||
/** | ||
* Joomla! Jea plugin. | ||
* | ||
*/ | ||
class PlgSystemJea extends CMSPlugin implements SubscriberInterface | ||
{ | ||
|
||
/** | ||
* Returns an array of events this subscriber will listen to. | ||
* | ||
* @return array | ||
* | ||
* @since 4.1.3 | ||
*/ | ||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
ApplicationEvents::BEFORE_EXECUTE => 'registerCommands', | ||
]; | ||
} | ||
|
||
public function registerCommands(): void | ||
{ | ||
$container = Factory::getContainer(); | ||
$writableLoader = $container->get(WritableLoaderInterface::class); | ||
assert($writableLoader instanceof WritableLoaderInterface); | ||
|
||
$container->share( | ||
GatewaysExportCommand::class, | ||
function () { | ||
return new GatewaysExportCommand(); | ||
}, | ||
true, | ||
); | ||
|
||
$container->share( | ||
GatewaysImportCommand::class, | ||
function () { | ||
return new GatewaysImportCommand(); | ||
}, | ||
true, | ||
); | ||
|
||
$writableLoader->add('jea:gateways:export', GatewaysExportCommand::class); | ||
$writableLoader->add('jea:gateways:import', GatewaysImportCommand::class); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<extension type="plugin" group="system" method="upgrade"> | ||
<name>plg_system_jea</name> | ||
<author>Sylvain Philip</author> | ||
<creationDate>2023-03</creationDate> | ||
<copyright>(C) 2006 Open Source Matters, Inc.</copyright> | ||
<license>GNU General Public License version 2 or later; see LICENSE.txt</license> | ||
<authorEmail>[email protected]</authorEmail> | ||
<authorUrl>www.sphilip.com</authorUrl> | ||
<version>1.0.0</version> | ||
<description>PLG_JEA_XML_DESCRIPTION</description> | ||
<namespace path="src">Joomla\Plugin\System\Jea</namespace> | ||
<files> | ||
<filename plugin="jea">jea.php</filename> | ||
<folder>language</folder> | ||
<folder>src</folder> | ||
</files> | ||
<config /> | ||
</extension> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PLG_SYSTEM_JEA="System - JEA" | ||
PLG_JEA_XML_DESCRIPTION="Adds specific JEA commands to the Joomla! cli console." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
|
||
PLG_SYSTEM_JEA="Système - JEA" | ||
PLG_JEA_XML_DESCRIPTION="Ce plugin ajoute des commandes spécifiques à JEA dans la console CLI Joomla!." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
namespace Joomla\Plugin\System\Jea\Console; | ||
|
||
use Joomla\CMS\Factory; | ||
use Joomla\Console\Command\AbstractCommand; | ||
use Symfony\Component\Console\Input\InputInterface; | ||
use Symfony\Component\Console\Output\OutputInterface; | ||
|
||
require_once JPATH_ADMINISTRATOR . '/components/com_jea/gateways/dispatcher.php'; | ||
|
||
/** | ||
* This command runs JEA gateways jobs | ||
*/ | ||
abstract class GatewaysCommand extends AbstractCommand | ||
{ | ||
protected $task = ''; | ||
|
||
/** | ||
* Entry point for CLI script | ||
* | ||
* @return integer the parents result | ||
*/ | ||
protected function doExecute(InputInterface $input, OutputInterface $output): int | ||
{ | ||
Factory::getApplication()->getLanguage()->load('com_jea', JPATH_ADMINISTRATOR . '/components/com_jea'); | ||
$dispatcher = \GatewaysEventDispatcher::getInstance(); | ||
$dispatcher->loadGateways(); | ||
$dispatcher->trigger($this->task); | ||
|
||
return 0; | ||
} | ||
|
||
/** | ||
* Configure the command. | ||
* | ||
* @return void | ||
* | ||
* @since 4.0.0 | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$help = "<info>%command.name%</info> Execute JEA gateways {$this->task} jobs | ||
\nUsage: <info>php %command.full_name%</info>"; | ||
$this->setDescription('Run JEA gateways ' . $this->task . ' jobs'); | ||
$this->setHelp($help); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Joomla\Plugin\System\Jea\Console; | ||
|
||
/** | ||
* This command runs JEA gateways export jobs | ||
*/ | ||
class GatewaysExportCommand extends GatewaysCommand | ||
{ | ||
protected static $defaultName = 'jea:gateways:export'; | ||
|
||
/** | ||
* Configure the command. | ||
* | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->task = 'export'; | ||
|
||
parent::configure(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
namespace Joomla\Plugin\System\Jea\Console; | ||
|
||
/** | ||
* This command runs JEA gateways export jobs | ||
*/ | ||
class GatewaysImportCommand extends GatewaysCommand | ||
{ | ||
protected static $defaultName = 'jea:gateways:import'; | ||
|
||
/** | ||
* Configure the command. | ||
* | ||
* @return void | ||
*/ | ||
protected function configure(): void | ||
{ | ||
$this->task = 'import'; | ||
|
||
parent::configure(); | ||
} | ||
} |