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 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 | ||||
{ | { | ||||
/** | /** | ||||
* Reference to global kApplication instance | * Reference to global kApplication instance | ||||
* | * | ||||
* @var \kApplication. | * @var \kApplication. | ||||
*/ | */ | ||||
protected $Application = null; | protected $Application = null; | ||||
/** | /** | ||||
* Connection to database. | * Connection to database. | ||||
* | * | ||||
* @var \IDBConnection | * @var \IDBConnection | ||||
*/ | */ | ||||
protected $Conn = null; | protected $Conn = null; | ||||
/** | /** | ||||
* Console IO. | |||||
* | |||||
* @var ConsoleIO | |||||
*/ | |||||
protected $io; | |||||
/** | |||||
* Sets the application instance for this command. | * Sets the application instance for this command. | ||||
* | * | ||||
* @param ConsoleApplication $application An Application instance. | * @param ConsoleApplication $application An Application instance. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
public function setApplication(ConsoleApplication $application = null) | public function setApplication(ConsoleApplication $application = null) | ||||
{ | { | ||||
Show All 18 Lines | |||||
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. | |||||
$this->io = new ConsoleIO($input, $output, $this->getHelperSet()); | |||||
} | } | ||||
} | } |