Changeset View
Changeset View
Standalone View
Standalone View
branches/5.3.x/core/kernel/Console/Command/RunScheduledTaskCommand.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 RunScheduledTaskCommand extends AbstractCommand implements CompletionAwareInterface | class RunScheduledTaskCommand extends AbstractCommand | ||||
{ | { | ||||
/** | /** | ||||
* Configures the current command. | * Configures the current command. | ||||
* | * | ||||
* @return void | * @return void | ||||
*/ | */ | ||||
protected function configure() | protected function configure() | ||||
Show All 32 Lines | |||||
$scheduled_tasks = $this->Application->EventManager->getScheduledTasks(); | $scheduled_tasks = $this->Application->EventManager->getScheduledTasks(); | ||||
$result = $this->Application->EventManager->runScheduledTask($scheduled_tasks[$scheduled_task_name]); | $result = $this->Application->EventManager->runScheduledTask($scheduled_tasks[$scheduled_task_name]); | ||||
return $result ? 0 : 64; | return $result ? 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 === 'scheduled_task_name' ) { | if ( $argumentName === 'scheduled_task_name' ) { | ||||
return $this->getScheduledTaskNames(); | return $this->getScheduledTaskNames(); | ||||
} | } | ||||
return array(); | return $suggestions; | ||||
} | } | ||||
/** | /** | ||||
* Returns scheduled task names. | * Returns scheduled task names. | ||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
protected function getScheduledTaskNames() | protected function getScheduledTaskNames() | ||||
{ | { | ||||
$scheduled_tasks = $this->Application->EventManager->getScheduledTasks(); | $scheduled_tasks = $this->Application->EventManager->getScheduledTasks(); | ||||
return array_keys($scheduled_tasks); | return array_keys($scheduled_tasks); | ||||
} | } | ||||
} | } |