mirror of
https://github.com/Icinga/icingaweb2-module-director.git
synced 2025-07-30 09:14:09 +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
|
||||
';
|
||||
|
||||
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();
|
||||
|
Loading…
x
Reference in New Issue
Block a user