cli/core: provide a CLI action for helper methods

This commit is contained in:
Thomas Gelf 2016-03-16 23:43:27 +01:00
parent 404c1a7164
commit 228f72db91
2 changed files with 25 additions and 4 deletions

View File

@ -0,0 +1,16 @@
<?php
namespace Icinga\Module\Director\Clicommands;
use Icinga\Module\Director\Cli\Command;
use Icinga\Module\Director\PlainObjectRenderer;
class CoreCommand extends Command
{
public function constantsAction()
{
foreach ($this->api()->getConstants() as $name => $value) {
printf("const %s = %s\n", $name, PlainObjectRenderer::render($value));
}
}
}

View File

@ -116,16 +116,21 @@ for (k => v in globals) {
constants
';
foreach ($this->client->post(
'console/execute-script',
array('command' => $command)
)->getSingleResult() as $row) {
foreach ($this->runConsoleCommand($command)->getSingleResult() as $row) {
$constants[$row->name] = $row->value;
}
return $constants;
}
protected function runConsoleCommand($command)
{
return $this->client->post(
'console/execute-script',
array('command' => $command)
);
}
public function getConstant($name)
{
$constants = $this->getConstants();