Dependency: prepare var rendering, cleanup
This commit is contained in:
parent
8f4a93dd08
commit
adace00df4
|
@ -188,60 +188,57 @@ class IcingaDependencyForm extends DirectorObjectForm
|
|||
*/
|
||||
protected function addObjectsElement()
|
||||
{
|
||||
$this->addElement(
|
||||
'text',
|
||||
'parent_host',
|
||||
array(
|
||||
'label' => $this->translate('Parent Host'),
|
||||
'description' => $this->translate(
|
||||
'The parent host.'
|
||||
),
|
||||
'class' => "autosubmit director-suggest",
|
||||
'data-suggestion-context' => 'hostnames',
|
||||
'order' => 10,
|
||||
'required' => $this->isObject(),
|
||||
'value' => $this->getObject()->get('parent_host')
|
||||
$dependency = $this->getObject();
|
||||
$parentHost = $dependency->get('parent_host');
|
||||
if ($parentHost === null) {
|
||||
$parentHost = $dependency->get('parent_host_var');
|
||||
}
|
||||
$this->addElement('text', 'parent_host', [
|
||||
'label' => $this->translate('Parent Host'),
|
||||
'description' => $this->translate(
|
||||
'The parent host.'
|
||||
),
|
||||
'class' => "autosubmit director-suggest",
|
||||
'data-suggestion-context' => 'hostnames',
|
||||
'order' => 10,
|
||||
'required' => $this->isObject(),
|
||||
'value' => $parentHost
|
||||
]);
|
||||
$sentParent = $this->getSentOrObjectValue('parent_host');
|
||||
|
||||
)
|
||||
);
|
||||
$sent_parent=$this->getSentOrObjectValue("parent_host");
|
||||
|
||||
if (!empty($sent_parent) || $this->object->isApplyRule()) {
|
||||
$this->addElement(
|
||||
'text',
|
||||
'parent_service',
|
||||
array(
|
||||
if (!empty($sentParent) || $dependency->isApplyRule()) {
|
||||
$parentService = $dependency->get('parent_service');
|
||||
if ($parentService === null) {
|
||||
$parentService = $dependency->get('parent_service_var');
|
||||
}
|
||||
$this->addElement('text', 'parent_service', [
|
||||
'label' => $this->translate('Parent Service'),
|
||||
'description' => $this->translate(
|
||||
'Optional. The parent service. If omitted this dependency object is treated as host dependency.'
|
||||
'Optional. The parent service. If omitted this dependency'
|
||||
. ' object is treated as host dependency.'
|
||||
),
|
||||
'class' => "autosubmit director-suggest",
|
||||
'data-suggestion-context' => 'servicenames',
|
||||
'data-suggestion-for-host' => $sent_parent,
|
||||
'data-suggestion-for-host' => $sentParent,
|
||||
'order' => 20,
|
||||
'value' => $this->getObject()->get('parent_service')
|
||||
)
|
||||
);
|
||||
'value' => $parentService
|
||||
]);
|
||||
}
|
||||
|
||||
// If configuring Object, allow selection of child host and/or service,
|
||||
// otherwise apply rules will determine child object.
|
||||
if ($this->isObject()) {
|
||||
$this->addElement(
|
||||
'text',
|
||||
'child_host',
|
||||
array(
|
||||
'label' => $this->translate('Child Host'),
|
||||
'description' => $this->translate(
|
||||
'The child host.'
|
||||
),
|
||||
'value' => $this->getObject()->get('child_host'),
|
||||
'order' => 30,
|
||||
'class' => "autosubmit director-suggest",
|
||||
'required' => $this->isObject(),
|
||||
'data-suggestion-context' => 'hostnames',
|
||||
)
|
||||
);
|
||||
if ($dependency->isObject()) {
|
||||
$this->addElement('text', 'child_host', [
|
||||
'label' => $this->translate('Child Host'),
|
||||
'description' => $this->translate(
|
||||
'The child host.'
|
||||
),
|
||||
'value' => $dependency->get('child_host'),
|
||||
'order' => 30,
|
||||
'class' => "autosubmit director-suggest",
|
||||
'required' => $this->isObject(),
|
||||
'data-suggestion-context' => 'hostnames',
|
||||
]);
|
||||
|
||||
$sent_child=$this->getSentOrObjectValue("child_host");
|
||||
|
||||
|
|
|
@ -60,6 +60,13 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
'ignore_soft_states' => 'ignore_soft_states'
|
||||
];
|
||||
|
||||
protected $propertiesNotForRendering = [
|
||||
'id',
|
||||
'object_name',
|
||||
'object_type',
|
||||
'apply_to',
|
||||
];
|
||||
|
||||
public function getUniqueIdentifier()
|
||||
{
|
||||
return $this->getObjectName();
|
||||
|
@ -107,20 +114,6 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
return $object;
|
||||
}
|
||||
|
||||
/**
|
||||
* Do not render internal property apply_to
|
||||
*
|
||||
* Avoid complaints for method names with underscore:
|
||||
* @codingStandardsIgnoreStart
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderApply_to()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
* @throws ConfigurationError
|
||||
|
@ -318,6 +311,21 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render parent_host_var as parent_host
|
||||
* @codingStandardsIgnoreStart
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderParent_host_var()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
return c::renderKeyValue(
|
||||
'parent_host',
|
||||
$this->get('parent_host_var')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render child_service_id as host_name
|
||||
*
|
||||
|
@ -360,6 +368,21 @@ class IcingaDependency extends IcingaObject implements ExportInterface
|
|||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Render parent_service_var as parent_service_name
|
||||
* @codingStandardsIgnoreStart
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function renderParent_service_var()
|
||||
{
|
||||
// @codingStandardsIgnoreEnd
|
||||
return c::renderKeyValue(
|
||||
'parent_service',
|
||||
$this->get('parent_host_var')
|
||||
);
|
||||
}
|
||||
|
||||
//special case for parent service set as plain string for Apply rules
|
||||
public function renderParent_service_by_name()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue