/** * Returns the value of variable for the given CmdbObject * @param CmdbObject $object the object to get the value */ public function getValue(\yourCMDB\entities\CmdbObject $object) { //get ObjectController $objectController = ObjectController::create(); //get object type config $config = CmdbConfig::create(); $configObjecttype = $config->getObjectTypeConfig(); $value = $this->defaultValue; //if there is a configuration for that object type //use the content of the specified field as value $objectType = $object->getType(); if (isset($this->fieldValue[$objectType]['name'])) { $fieldname = $this->fieldValue[$objectType]['name']; $value = $object->getFieldvalue($fieldname); //check if field is an object reference (type objectref) if (preg_match('/objectref-.*/', $configObjecttype->getFieldType($objectType, $fieldname)) == 1) { try { //get referenced object $refObject = $objectController->getObject($value, "yourCMDB-exporter"); //get value of referenced field if configured if ($this->fieldValue[$objectType]['refobjectfield'] != "") { $refFieldname = $this->fieldValue[$objectType]['refobjectfield']; $value = $refObject->getFieldvalue($refFieldname); } } catch (Exception $e) { } } } //return the value return $value; }