Skip to content

Commit

Permalink
updated command to allow choosing application "client"
Browse files Browse the repository at this point in the history
  • Loading branch information
Skullbock committed Apr 6, 2020
1 parent 05d03d6 commit 7989459
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 9 deletions.
Binary file modified .DS_Store
Binary file not shown.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ build/*
!build/packages
build/packages/*
!build/pkg_joomlacommands.xml
!libraries/joomla-commands
libraries/joomla-commands/vendor
node_modules
package-lock.json
.DS_Store
11 changes: 2 additions & 9 deletions bin/console
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,14 @@ define('JDEBUG', $config->debug);

require_once JPATH_LIBRARIES . '/joomla-commands/vendor/autoload.php';

use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Symfony\Component\Console\Application;
use Weble\JoomlaCommands\Application\Application;

class ApplicationConsole extends JApplicationCli
{
public function doExecute()
{
Factory::$application = $this;

$application = new Application();

PluginHelper::importPlugin('console', null, true, $this->dispatcher);
$this->triggerEvent('onGetConsoleCommands', [$application]);

$application->setJoomlaCliApplication($this);
$application->run();
}
}
Expand Down
58 changes: 58 additions & 0 deletions libraries/joomla-commands/Application/Application.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
<?php

namespace Weble\JoomlaCommands\Application;

use Joomla\CMS\Application\CliApplication;
use Joomla\CMS\Application\CMSApplication;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class Application extends \Symfony\Component\Console\Application
{
/**
* @var InputInterface
*/
protected $input;
/**
* @var OutputInterface
*/
protected $output;
/**
* @var CliApplication
*/
protected $joomlaCliApplication;

public function doRun(InputInterface $input, OutputInterface $output)
{
$this->input = $input;
$this->output = $output;

$this->configureJoomlaApplication();
$this->loadCommandsFromPlugins();


return parent::doRun($input, $output); // TODO: Change the autogenerated stub
}

public function setJoomlaCliApplication(CliApplication $app): self
{
$this->joomlaCliApplication = $app;
return $this;
}

protected function configureJoomlaApplication()
{
$clientId = $this->input->hasParameterOption(['--ansi'], true) ?: 'site';
$application = CMSApplication::getInstance($clientId);

Factory::$application = $application;
}

protected function loadCommandsFromPlugins()
{
PluginHelper::importPlugin('console', null, true);
$this->joomlaCliApplication->triggerEvent('onGetConsoleCommands', [$this]);
}
}
19 changes: 19 additions & 0 deletions libraries/joomla-commands/joomla-commands.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="library" version="3.9" method="upgrade">
<!-- Please use a unique name to make uninstall to work. Should be identical to your manifest filename. -->
<name>Joomla Commands - Library</name>
<libraryname>joomla-commands</libraryname>
<author>Weble Srl</author>
<version>1.0.0</version>
<creationDate>April 2020</creationDate>
<copyright>(C) 2020 Weble Srl</copyright>
<license>MIT</license>
<authorEmail>[email protected]</authorEmail>
<authorUrl>http://www.weble.it</authorUrl>
<description>Joomla Commands - Library</description>

<files>
<folder>vendor</folder>
<file>joomla-commands.xml</file>
</files>
</extension>

0 comments on commit 7989459

Please sign in to comment.