ListDataDefinition::getClass

public ListDataDefinition::getClass()

Returns the class used for creating the typed data object.

If not specified, the default class of the data type will be returned.

Return value

string The class used for creating the typed data object.

Overrides DataDefinition::getClass

File

core/lib/Drupal/Core/TypedData/ListDataDefinition.php, line 74

Class

ListDataDefinition
A typed data definition class for defining lists.

Namespace

Drupal\Core\TypedData

Code

public function getClass() {
  $class = isset($this->definition['class']) ? $this->definition['class'] : NULL;
  if (!empty($class)) {
    return $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'];
  }
}
doc_Drupal
2016-10-29 09:23:28
Comments
Leave a Comment

Please login to continue.