mirror of
https://github.com/Icinga/icingaweb2-module-businessprocess.git
synced 2026-02-18 10:20:25 -05:00
Drop obsolete class NoDuplicateChildrenValidator
This commit is contained in:
parent
890df4be7c
commit
0ea04f898f
1 changed files with 0 additions and 57 deletions
|
|
@ -1,57 +0,0 @@
|
|||
<?php
|
||||
|
||||
namespace Icinga\Module\Businessprocess\Web\Form\Validator;
|
||||
|
||||
use Icinga\Module\Businessprocess\BpConfig;
|
||||
use Icinga\Module\Businessprocess\BpNode;
|
||||
use Icinga\Module\Businessprocess\Forms\EditNodeForm;
|
||||
use Icinga\Module\Businessprocess\Web\Form\QuickForm;
|
||||
use Zend_Validate_Abstract;
|
||||
|
||||
class NoDuplicateChildrenValidator extends Zend_Validate_Abstract
|
||||
{
|
||||
const CHILD_FOUND = 'childFound';
|
||||
|
||||
/** @var QuickForm */
|
||||
protected $form;
|
||||
|
||||
/** @var BpConfig */
|
||||
protected $bp;
|
||||
|
||||
/** @var BpNode */
|
||||
protected $parent;
|
||||
|
||||
/** @var string */
|
||||
protected $label;
|
||||
|
||||
public function __construct(QuickForm $form, BpConfig $bp, BpNode $parent = null)
|
||||
{
|
||||
$this->form = $form;
|
||||
$this->bp = $bp;
|
||||
$this->parent = $parent;
|
||||
|
||||
$this->_messageVariables['label'] = 'label';
|
||||
$this->_messageTemplates = [
|
||||
self::CHILD_FOUND => mt('businessprocess', '%label% is already defined in this process')
|
||||
];
|
||||
}
|
||||
|
||||
public function isValid($value)
|
||||
{
|
||||
if ($this->parent === null) {
|
||||
$found = $this->bp->hasRootNode($value);
|
||||
} elseif ($this->form instanceof EditNodeForm && $this->form->getNode()->getName() === $value) {
|
||||
$found = false;
|
||||
} else {
|
||||
$found = $this->parent->hasChild($value);
|
||||
}
|
||||
|
||||
if (! $found) {
|
||||
return true;
|
||||
}
|
||||
|
||||
$this->label = $this->form->getElement('children')->getMultiOptions()[$value];
|
||||
$this->_error(self::CHILD_FOUND);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue