mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-06-26 00:58:52 -04:00
Add SPDX license headers and mark source files as GPL-3.0-or-later to preserve the option to relicense under later GPL versions.
51 lines
1.2 KiB
PHP
51 lines
1.2 KiB
PHP
<?php
|
|
|
|
// SPDX-FileCopyrightText: 2019 Icinga GmbH <https://icinga.com>
|
|
// SPDX-License-Identifier: GPL-3.0-or-later
|
|
|
|
namespace Icinga\Module\Businessprocess\Modification;
|
|
|
|
use Icinga\Module\Businessprocess\BpConfig;
|
|
use Icinga\Module\Businessprocess\Common\Sort;
|
|
|
|
class NodeCopyAction extends NodeAction
|
|
{
|
|
use Sort;
|
|
|
|
/**
|
|
* @param BpConfig $config
|
|
* @return bool
|
|
*/
|
|
public function appliesTo(BpConfig $config)
|
|
{
|
|
$name = $this->getNodeName();
|
|
|
|
if (! $config->hasBpNode($name)) {
|
|
$this->error('Process "%s" not found', $name);
|
|
}
|
|
|
|
if ($config->hasRootNode($name)) {
|
|
$this->error('A toplevel node with name "%s" already exists', $name);
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
/**
|
|
* @param BpConfig $config
|
|
*/
|
|
public function applyTo(BpConfig $config)
|
|
{
|
|
$name = $this->getNodeName();
|
|
|
|
$display = 1;
|
|
if ($config->getMetadata()->isManuallyOrdered()) {
|
|
$rootNodes = self::applyManualSorting($config->getRootNodes());
|
|
$display = end($rootNodes)->getDisplay() + 1;
|
|
}
|
|
|
|
$config->addRootNode($name)
|
|
->getBpNode($name)
|
|
->setDisplay($display);
|
|
}
|
|
}
|