Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/kernel/Console/Command/AbstractCommand.php
Show All 10 Lines | |||||
* or other free or open source software licenses. | * or other free or open source software licenses. | ||||
* See http://www.in-portal.org/license for copyright notices and details. | * See http://www.in-portal.org/license for copyright notices and details. | ||||
*/ | */ | ||||
namespace InPortal\Core\kernel\Console\Command; | namespace InPortal\Core\kernel\Console\Command; | ||||
use InPortal\Core\kernel\Console\ConsoleApplication; | use InPortal\Core\kernel\Console\ConsoleApplication; | ||||
use Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface; | |||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; | |||||
use InPortal\Core\kernel\Console\ConsoleIO; | use InPortal\Core\kernel\Console\ConsoleIO; | ||||
use Symfony\Component\Console\Command\Command as SymfonyCommand; | use Symfony\Component\Console\Command\Command as SymfonyCommand; | ||||
use Symfony\Component\Console\Input\InputInterface; | use Symfony\Component\Console\Input\InputInterface; | ||||
use Symfony\Component\Console\Output\OutputInterface; | use Symfony\Component\Console\Output\OutputInterface; | ||||
defined('FULL_PATH') or die('restricted access!'); | defined('FULL_PATH') or die('restricted access!'); | ||||
abstract class AbstractCommand extends SymfonyCommand implements IConsoleCommand | abstract class AbstractCommand extends SymfonyCommand implements IConsoleCommand, CompletionAwareInterface | ||||
{ | { | ||||
/** | /** | ||||
* Reference to global kApplication instance | * Reference to global kApplication instance | ||||
* | * | ||||
* @var \kApplication. | * @var \kApplication. | ||||
*/ | */ | ||||
protected $Application = null; | protected $Application = null; | ||||
Show All 26 Lines | |||||
// For disabled commands $application is not set. | // For disabled commands $application is not set. | ||||
if ( isset($application) ) { | if ( isset($application) ) { | ||||
$this->Application = $application->getKernelApplication(); | $this->Application = $application->getKernelApplication(); | ||||
$this->Conn =& $this->Application->GetADODBConnection(); | $this->Conn =& $this->Application->GetADODBConnection(); | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Return possible values for the named option | |||||
* | |||||
* @param string $optionName Option name. | |||||
* @param CompletionContext $context Completion context. | |||||
* | |||||
* @return array | |||||
*/ | |||||
public function completeOptionValues($optionName, CompletionContext $context) | |||||
{ | |||||
$this->initDependencies(); | |||||
return array(); | |||||
} | |||||
/** | |||||
* Return possible values for the named argument | |||||
* | |||||
* @param string $argumentName Argument name. | |||||
* @param CompletionContext $context Completion context. | |||||
* | |||||
* @return array | |||||
*/ | |||||
public function completeArgumentValues($argumentName, CompletionContext $context) | |||||
{ | |||||
$this->initDependencies(); | |||||
return array(); | |||||
} | |||||
/** | |||||
* Perform additional validation of the input. | * Perform additional validation of the input. | ||||
* | * | ||||
* @param InputInterface $input An InputInterface instance. | * @param InputInterface $input An InputInterface instance. | ||||
* @param OutputInterface $output An OutputInterface instance. | * @param OutputInterface $output An OutputInterface instance. | ||||
* | * | ||||
* @return void | * @return void | ||||
* @throws \RuntimeException When not all required arguments were passed. | * @throws \RuntimeException When not all required arguments were passed. | ||||
*/ | */ | ||||
protected function initialize(InputInterface $input, OutputInterface $output) | protected function initialize(InputInterface $input, OutputInterface $output) | ||||
{ | { | ||||
$arguments = array_filter($input->getArguments()); | $arguments = array_filter($input->getArguments()); | ||||
// Consider required arguments passed with empty values as an error. | // Consider required arguments passed with empty values as an error. | ||||
if ( count($arguments) < $this->getDefinition()->getArgumentRequiredCount() ) { | if ( count($arguments) < $this->getDefinition()->getArgumentRequiredCount() ) { | ||||
throw new \RuntimeException('Not enough arguments.'); | throw new \RuntimeException('Not enough arguments.'); | ||||
} | } | ||||
// Don't use factory because of "classmap:rebuild" command. | // Don't use factory because of "classmap:rebuild" command. | ||||
$this->io = new ConsoleIO($input, $output, $this->getHelperSet()); | $this->io = new ConsoleIO($input, $output, $this->getHelperSet()); | ||||
$this->initDependencies(); | |||||
} | |||||
/** | |||||
* Initializes dependencies. | |||||
* | |||||
* @return void | |||||
*/ | |||||
protected function initDependencies() | |||||
{ | |||||
} | } | ||||
} | } |