protected function determineAttributeValue($attribute_name) { $value = ''; if ($this->hasOption('value')) { return $this->getOption('value'); } $value_path = $this->getOption('attribute_value_path'); if (!empty($value_path)) { $value = AttributeValuePath::getAttributeValueByPath($this->getPayload('resource'), $value_path); } else { $value = $this->getPayload('resource')->getValue($attribute_name); } // @todo introduce nested rendering or smarter mechanisms or error message for resources and other known types? if (is_object($value)) { if ($value instanceof DateTimeInterface) { $value = $value->format(TimestampAttribute::FORMAT_ISO8601); } elseif (!$value instanceof ComplexValueInterface) { $value = sprintf('Attribute "%s" (type "%s") – value of type object (%s): %s', $attribute_name, get_class($this->attribute), get_class($value), StringToolkit::getObjectAsString($value)); } else { // it's a complex value so we should not convert the object to string or similar // the specific renderer for that attribute might want to use the actual object } } elseif (is_array($value)) { $value = sprintf('Attribute "%s" – value of type array with keys: %s', $attribute_name, print_r(array_keys($value), true)); } else { // $value = StringToolkit::getAsString($value); } return $value; }