/** * Calculate the label of a property to se in "show" view. * * @param PropertyInterface $property The property for which the label shall be calculated. * * @return string */ protected function getPropertyLabel(PropertyInterface $property) { $environment = $this->getEnvironment(); $definition = $environment->getDataDefinition(); $label = $environment->getTranslator()->translate($property->getLabel(), $definition->getName()); if (!$label) { $label = $environment->getTranslator()->translate('MSC.' . $property->getName()); } if (is_array($label)) { $label = $label[0]; } if (!$label) { $label = $property->getName(); } return $label; }
/** * Parse the label of a single property. * * @param PropertyInterface $property The property to parse the label for. * * @param string|array $label The label value. * * @return void */ protected function parseSinglePropertyLabel(PropertyInterface $property, $label) { if (!$property->getLabel()) { if (is_array($label)) { $lang = $label; $label = reset($lang); $description = next($lang); $property->setDescription($description); } $property->setLabel($label); } }