Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/kernel/Console/Command/RunEventCommand.php
Show All 9 Lines | |||||
* or is derivative of works licensed under the GNU General Public License | * or is derivative of works licensed under the GNU General Public License | ||||
* 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 Stecman\Component\Symfony\Console\BashCompletion\Completion\CompletionAwareInterface; | |||||
use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; | use Stecman\Component\Symfony\Console\BashCompletion\CompletionContext; | ||||
use Symfony\Component\Console\Input\InputArgument; | use Symfony\Component\Console\Input\InputArgument; | ||||
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!'); | ||||
class RunEventCommand extends AbstractCommand implements CompletionAwareInterface | class RunEventCommand extends AbstractCommand | ||||
{ | { | ||||
/** | /** | ||||
* Configures the current command. | * Configures the current command. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
protected function configure() | protected function configure() | ||||
Show All 22 Lines | |||||
$run_event = new \kEvent($event_name); | $run_event = new \kEvent($event_name); | ||||
$this->Application->HandleEvent($run_event); | $this->Application->HandleEvent($run_event); | ||||
return $run_event->status == \kEvent::erSUCCESS ? 0 : 64; | return $run_event->status == \kEvent::erSUCCESS ? 0 : 64; | ||||
} | } | ||||
/** | /** | ||||
* 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) | |||||
{ | |||||
return array(); | |||||
} | |||||
/** | |||||
* Return possible values for the named argument. | * Return possible values for the named argument. | ||||
* | * | ||||
* @param string $argumentName Argument name. | * @param string $argumentName Argument name. | ||||
* @param CompletionContext $context Completion context. | * @param CompletionContext $context Completion context. | ||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
public function completeArgumentValues($argumentName, CompletionContext $context) | public function completeArgumentValues($argumentName, CompletionContext $context) | ||||
{ | { | ||||
$suggestions = parent::completeArgumentValues($argumentName, $context); | |||||
if ( $argumentName === 'event_name' ) { | if ( $argumentName === 'event_name' ) { | ||||
$event_name = $context->getCurrentWord(); | $event_name = $context->getCurrentWord(); | ||||
// Suggest unit config prefixes. | // Suggest unit config prefixes. | ||||
if ( strpos($event_name, ':') === false ) { | if ( strpos($event_name, ':') === false ) { | ||||
return $this->Application->UnitConfigReader->getPrefixes(false); | return $this->Application->UnitConfigReader->getPrefixes(false); | ||||
} | } | ||||
Show All 20 Lines | |||||
if ( substr($method->getName(), 0, 2) === 'On' ) { | if ( substr($method->getName(), 0, 2) === 'On' ) { | ||||
$suggestions[] = $event->Prefix . ':' . $method->getName(); | $suggestions[] = $event->Prefix . ':' . $method->getName(); | ||||
} | } | ||||
} | } | ||||
return $suggestions; | return $suggestions; | ||||
} | } | ||||
return array(); | return $suggestions; | ||||
} | } | ||||
} | } |