X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;ds=sidebyside;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FTypedData%2FListDataDefinition.php;h=001c58b28759548fdaccec663e12e838d1998931;hb=refs%2Fheads%2Fd864;hp=3109cd2115678dd37f4b520930e1c83b12715fd8;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website 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; + } + }