Page MenuHomeIn-Portal Phabricator

ConsoleApplication.php
No OneTemporary

File Metadata

Created
Wed, Sep 24, 6:22 AM

ConsoleApplication.php

<?php
/**
* @version $Id: ConsoleApplication.php 16252 2015-09-27 06:34:45Z alex $
* @package In-Portal
* @copyright Copyright (C) 1997 - 2015 Intechnic. All rights reserved.
* @license GNU/GPL
* In-Portal is Open Source software.
* This means that this software may have been modified pursuant
* the GNU General Public License, and as distributed it includes
* or is derivative of works licensed under the GNU General Public License
* or other free or open source software licenses.
* See http://www.in-portal.org/license for copyright notices and details.
*/
namespace InPortal\Core\kernel\Console;
use Symfony\Component\Console\Application as BaseApplication;
use Symfony\Component\Console\Command\Command;
defined('FULL_PATH') or die('restricted access!');
class ConsoleApplication extends BaseApplication
{
/**
* Reference to global kApplication instance.
*
* @var \kApplication
*/
protected $Application = null;
/**
* Connection to database
*
* @var \IDBConnection
*/
protected $Conn = null;
/**
* Constructor.
*
* @param string $name The name of the application.
* @param string $version The version of the application.
*/
public function __construct($name = 'UNKNOWN', $version = 'UNKNOWN')
{
$this->Application =& \kApplication::Instance();
$this->Conn =& $this->Application->GetADODBConnection();
parent::__construct(
'In-Portal CLI',
$this->Application->ModuleInfo['Core']['Version'] . ' (PHP v' . phpversion() . ')'
);
}
/**
* Returns Kernel Application instance.
*
* @return \kApplication
*/
public function getKernelApplication()
{
return $this->Application;
}
/**
* Gets the default commands that should always be available.
*
* @return Command[] An array of default Command instances
*/
protected function getDefaultCommands()
{
$default_commands = parent::getDefaultCommands();
$command_provider_classes = $this->Application->getSubClasses(
'InPortal\Core\kernel\Console\IConsoleCommandProvider'
);
foreach ( $command_provider_classes as $command_provider_class ) {
/** @var IConsoleCommandProvider $command_provider */
$command_provider = new $command_provider_class();
$default_commands = array_merge($default_commands, $command_provider->getConsoleCommands());
}
return $default_commands;
}
}

Event Timeline