mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-09-26 03:09:11 +02:00
cli/core: provide a CLI action for helper methods
This commit is contained in:
parent
404c1a7164
commit
228f72db91
16
application/clicommands/CoreCommand.php
Normal file
16
application/clicommands/CoreCommand.php
Normal 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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -116,16 +116,21 @@ for (k => v in globals) {
|
|||||||
constants
|
constants
|
||||||
';
|
';
|
||||||
|
|
||||||
foreach ($this->client->post(
|
foreach ($this->runConsoleCommand($command)->getSingleResult() as $row) {
|
||||||
'console/execute-script',
|
|
||||||
array('command' => $command)
|
|
||||||
)->getSingleResult() as $row) {
|
|
||||||
$constants[$row->name] = $row->value;
|
$constants[$row->name] = $row->value;
|
||||||
}
|
}
|
||||||
|
|
||||||
return $constants;
|
return $constants;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected function runConsoleCommand($command)
|
||||||
|
{
|
||||||
|
return $this->client->post(
|
||||||
|
'console/execute-script',
|
||||||
|
array('command' => $command)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
public function getConstant($name)
|
public function getConstant($name)
|
||||||
{
|
{
|
||||||
$constants = $this->getConstants();
|
$constants = $this->getConstants();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user