/** * @param Core\Events\LoadFormDatas $event */ public static function execute(LoadFormDatasEvent $event) { $route = $event->getRoute(); $objectId = $event->getObjectId(); $parameters = $event->getParameters(); if ($route === '/centreon-administration/aclresource/update') { try { $allBasParameter = AclresourceBusinessActivitiesParams::getParameters($objectId, 'all_business_activities'); $event->addParameters(array('centreon-bam__aclresource_all_bas' => $allBasParameter['all_business_activities'])); } catch (\Exception $e) { } } }
/** * @param Core\Events\LoadFormDatas $event */ public static function execute(LoadFormDatasEvent $event) { $route = $event->getRoute(); $objectId = $event->getObjectId(); $parameters = $event->getParameters(); if ($route === '/centreon-administration/aclresource/update') { try { $allHostsParameter = AclresourceHostsParams::getParameters($objectId, 'all_hosts'); $event->addParameters(array('centreon-configuration__aclresource_all_hosts' => $allHostsParameter['all_hosts'])); } catch (\Exception $e) { } } }
/** * @param Core\Events\LoadFormDatas $event */ public static function execute(LoadFormDatasEvent $event) { $route = $event->getRoute(); $objectId = $event->getObjectId(); $parameters = $event->getParameters(); if ($route === '/centreon-configuration/poller/update') { try { $engineParameters = Engine::getParameters($objectId, "*"); $engineCompleteParameters = array(); foreach ($engineParameters as $key => $value) { $engineCompleteParameters['centreon-engine__' . $key] = $value; } $event->addParameters($engineCompleteParameters); } catch (\Exception $e) { } } }
/** * * @param array $defaultValues */ public function setDefaultValues($defaultValues, $objectId = "") { if (isset($objectId) && is_string($defaultValues)) { // Get the mapped columns for the object $objectColumns = $defaultValues::getColumns(); $fields = array_intersect($objectColumns, array_keys($this->formDefaults)); $fields = array_map(function ($field) { return "`" . $field . "`"; }, $fields); // Get the mapped values and if no value saved for the field, the default one is set $myValues = $defaultValues::getParameters($objectId, join(", ", $fields)); foreach ($myValues as $key => &$value) { if (is_null($value)) { $value = $this->formDefaults[$key]; } } // Merging with non-mapped form field and returns the values combined $eventDefaultValues = array_merge($myValues, array_diff_key($this->formDefaults, $myValues)); $events = Di::getDefault()->get('events'); $loadFormDatasEvent = new LoadFormDatasEvent($this->formRoute, $objectId, $eventDefaultValues); $events->emit('core.load.form.datas', array($loadFormDatasEvent)); $finalDefaultValues = $loadFormDatasEvent->getParameters(); $this->formHandler->setDefaults($finalDefaultValues); } elseif (is_array($defaultValues)) { foreach ($defaultValues as $k => $v) { $this->formDefaults[$k] = $v; } $this->formHandler->setDefaults($defaultValues); } }