Skip to content
Snippets Groups Projects
Verified Commit 6eafe72d authored by Lee Rowlands's avatar Lee Rowlands
Browse files

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

parent a9d3f0ab
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
......@@ -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'];
}
/**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment