ShowController: try hard to render erraneous...

...activity log entries
This commit is contained in:
Thomas Gelf 2016-10-09 13:12:18 +00:00
parent cf063180d2
commit 3423ddf605
1 changed files with 24 additions and 6 deletions

View File

@ -7,6 +7,7 @@ use Icinga\Module\Director\IcingaConfig\IcingaConfig;
use Icinga\Module\Director\Web\Controller\ActionController; use Icinga\Module\Director\Web\Controller\ActionController;
use Icinga\Module\Director\Util; use Icinga\Module\Director\Util;
use Icinga\Module\Director\Objects\IcingaObject; use Icinga\Module\Director\Objects\IcingaObject;
use Exception;
class ShowController extends ActionController class ShowController extends ActionController
{ {
@ -81,7 +82,17 @@ class ShowController extends ActionController
$object->object_type = 'object'; $object->object_type = 'object';
} }
$object->renderToConfig($config); try {
$object->renderToConfig($config);
} catch (Exception $e) {
$config->configFile(
'failed-to-render'
)->prepend(
"/** Failed to render this object **/\n"
. '/* ' . $e->getMessage() . ' */'
);
}
return $config; return $config;
} }
@ -247,10 +258,17 @@ class ShowController extends ActionController
protected function createObject($type, $props) protected function createObject($type, $props)
{ {
$props = json_decode($props); $props = json_decode($props);
return IcingaObject::createByType($type, array( $newProps = array(
'object_name' => $props->object_name, 'object_name' => $props->object_name
'object_type' => $props->object_type, );
), $this->db())->setProperties((array) $props); if (property_exists($props, 'object_type')) {
return IcingaObject::createByType($type, (array) $props, $this->db()); $newProps['object_type'] = $props->object_type;
}
return IcingaObject::createByType(
$type,
$newProps,
$this->db()
)->setProperties((array) $props);
} }
} }