Commit 6eafe72d authored by larowlan's avatar larowlan

Issue #2934096 by kiamlaluno, joelpittet: Simplify the ListDataDefinition::getClass() code

parent a9d3f0ab
......@@ -72,20 +72,18 @@ public function setDataType($type) {
* {@inheritdoc}
*/
public function getClass() {
$class = isset($this->definition['class']) ? $this->definition['class'] : NULL;
if (!empty($class)) {
return $class;
if (!empty($this->definition['class'])) {
return $this->definition['class'];
}
else {
// If a list definition is used but no class has been specified, derive
// the default list class from the item type.
$item_type_definition = \Drupal::typedDataManager()
->getDefinition($this->getItemDefinition()->getDataType());
if (!$item_type_definition) {
throw new \LogicException("An invalid data type '{$this->getItemDefinition()->getDataType()}' has been specified for list items");
}
return $item_type_definition['list_class'];
// If a list definition is used but no class has been specified, derive the
// default list class from the item type.
$item_type_definition = \Drupal::typedDataManager()
->getDefinition($this->getItemDefinition()->getDataType());
if (!$item_type_definition) {
throw new \LogicException("An invalid data type '{$this->getItemDefinition()->getDataType()}' has been specified for list items");
}
return $item_type_definition['list_class'];
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment