X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FTypedData%2FListDataDefinition.php;fp=web%2Fcore%2Flib%2FDrupal%2FCore%2FTypedData%2FListDataDefinition.php;h=001c58b28759548fdaccec663e12e838d1998931;hp=3109cd2115678dd37f4b520930e1c83b12715fd8;hb=af6d1fb995500ae68849458ee10d66abbdcfb252;hpb=680c79a86e3ed402f263faeac92e89fb6d9edcc0 diff --git a/web/core/lib/Drupal/Core/TypedData/ListDataDefinition.php b/web/core/lib/Drupal/Core/TypedData/ListDataDefinition.php index 3109cd211..001c58b28 100644 --- a/web/core/lib/Drupal/Core/TypedData/ListDataDefinition.php +++ b/web/core/lib/Drupal/Core/TypedData/ListDataDefinition.php @@ -72,20 +72,18 @@ class ListDataDefinition extends DataDefinition implements ListDataDefinitionInt * {@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']; } /** @@ -108,4 +106,13 @@ class ListDataDefinition extends DataDefinition implements ListDataDefinitionInt return $this; } + /** + * Magic method: Implements a deep clone. + */ + public function __clone() { + // Ensure the itemDefinition property is actually cloned by overwriting the + // original reference. + $this->itemDefinition = clone $this->itemDefinition; + } + }