diff -u b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php --- b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php +++ b/core/lib/Drupal/Core/Entity/Field/FieldItemBase.php @@ -25,8 +25,8 @@ /** * Overrides \Drupal\Core\TypedData\TypedData::__construct(). */ - public function __construct(array $definition, $plugin_id, array $plugin_definition, $name = NULL, TypedDataInterface $parent = NULL) { - parent::__construct($definition, $plugin_id, $plugin_definition, $name, $parent); + public function __construct(array $definition, $name = NULL, TypedDataInterface $parent = NULL) { + parent::__construct($definition, $name, $parent); // Initialize computed properties by default, such that they get cloned // with the whole item. foreach ($this->getPropertyDefinitions() as $name => $definition) { reverted: --- b/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php +++ a/core/lib/Drupal/Core/Entity/Field/Type/EntityWrapper.php @@ -61,8 +61,8 @@ /** * Overrides TypedData::__construct(). */ + public function __construct(array $definition, $name = NULL, TypedDataInterface $parent = NULL) { + parent::__construct($definition, $name, $parent); - public function __construct(array $definition, $plugin_id, array $plugin_definition, $name = NULL, TypedDataInterface $parent = NULL) { - parent::__construct($definition, $plugin_id, $plugin_definition, $name, $parent); $this->entityType = isset($this->definition['constraints']['EntityType']) ? $this->definition['constraints']['EntityType'] : NULL; } diff -u b/core/lib/Drupal/Core/Entity/Field/Type/Field.php b/core/lib/Drupal/Core/Entity/Field/Type/Field.php --- b/core/lib/Drupal/Core/Entity/Field/Type/Field.php +++ b/core/lib/Drupal/Core/Entity/Field/Type/Field.php @@ -36,8 +36,8 @@ /** * Overrides TypedData::__construct(). */ - public function __construct(array $definition, $plugin_id, array $plugin_definition, $name = NULL, TypedDataInterface $parent = NULL) { - parent::__construct($definition, $plugin_id, $plugin_definition, $name, $parent); + public function __construct(array $definition, $name = NULL, TypedDataInterface $parent = NULL) { + parent::__construct($definition, $name, $parent); // Always initialize one empty item as most times a value for at least one // item will be present. That way prototypes created by // \Drupal\Core\TypedData\TypedDataManager::getPropertyInstance() will diff -u b/core/lib/Drupal/Core/TypedData/TypedData.php b/core/lib/Drupal/Core/TypedData/TypedData.php --- b/core/lib/Drupal/Core/TypedData/TypedData.php +++ b/core/lib/Drupal/Core/TypedData/TypedData.php @@ -7,7 +7,6 @@ namespace Drupal\Core\TypedData; -use Drupal\Component\Plugin\PluginBase; use Drupal\Component\Plugin\PluginInspectionInterface; /** @@ -16,7 +15,7 @@ * Classes deriving from this base class have to declare $value * or override getValue() or setValue(). */ -abstract class TypedData extends PluginBase implements TypedDataInterface, PluginInspectionInterface { +abstract class TypedData implements TypedDataInterface, PluginInspectionInterface { /** * The data definition. @@ -44,10 +43,6 @@ * * @param array $definition * The data definition. - * @param string $plugin_id - * The plugin_id for the plugin instance. - * @param array $plugin_definition - * The plugin implementation definition. * @param string $name * (optional) The name of the created property, or NULL if it is the root * of a typed data tree. Defaults to NULL. @@ -57,10 +52,8 @@ * * @see Drupal\Core\TypedData\TypedDataManager::create() */ - public function __construct(array $definition, $plugin_id, array $plugin_definition, $name = NULL, TypedDataInterface $parent = NULL) { + public function __construct(array $definition, $name = NULL, TypedDataInterface $parent = NULL) { $this->definition = $definition; - $this->pluginId = $plugin_id; - $this->pluginDefinition = $plugin_definition; $this->parent = $parent; $this->name = $name; } @@ -73,6 +66,20 @@ } /** + * {@inheritdoc} + */ + public function getPluginId() { + return $this->definition['type']; + } + + /** + * {@inheritdoc} + */ + public function getPluginDefinition() { + return \Drupal::typedData()->getDefinition($this->definition['type']); + } + + /** * Implements \Drupal\Core\TypedData\TypedDataInterface::getDefinition(). */ public function getDefinition() { reverted: --- b/core/lib/Drupal/Core/TypedData/TypedDataFactory.php +++ a/core/lib/Drupal/Core/TypedData/TypedDataFactory.php @@ -57,8 +57,6 @@ if (!isset($class)) { throw new PluginException(sprintf('The plugin (%s) did not specify an instance class.', $plugin_id)); } + return new $class($configuration, $name, $parent); - - return new $class($configuration, $plugin_id, $type_definition, $name, $parent); } - } diff -u b/core/modules/entity_reference/lib/Drupal/entity_reference/Type/ConfigurableEntityReferenceItem.php b/core/modules/entity_reference/lib/Drupal/entity_reference/Type/ConfigurableEntityReferenceItem.php --- b/core/modules/entity_reference/lib/Drupal/entity_reference/Type/ConfigurableEntityReferenceItem.php +++ b/core/modules/entity_reference/lib/Drupal/entity_reference/Type/ConfigurableEntityReferenceItem.php @@ -162,7 +162,8 @@ * The name of the legacy callback, or NULL if it does not exist. */ protected function getLegacyCallback($hook) { - $module = $this->pluginDefinition['module']; + $definition = $this->getPluginDefinition(); + $module = $definition['module']; $callback = "{$module}_field_{$hook}"; if (function_exists($callback)) { return $callback; diff -u b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php --- b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigField.php @@ -102,7 +102,8 @@ * The name of the hook, e.g. 'presave', 'validate'. */ protected function legacyCallback($hook, $args = array()) { - $module = $this->pluginDefinition['module']; + $definition = $this->getPluginDefinition(); + $module = $definition['module']; $callback = "{$module}_field_{$hook}"; if (function_exists($callback)) { $entity = $this->getParent(); diff -u b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php --- b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php +++ b/core/modules/field/lib/Drupal/field/Plugin/field/field_type/LegacyConfigFieldItem.php @@ -116,7 +116,8 @@ * The name of the legacy callback, or NULL if it does not exist. */ protected function getLegacyCallback($hook) { - $module = $this->pluginDefinition['module']; + $definition = $this->getPluginDefinition(); + $module = $definition['module']; $callback = "{$module}_field_{$hook}"; if (function_exists($callback)) { return $callback; --- b/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php +++ a/core/modules/locale/lib/Drupal/locale/LocaleTypedConfig.php @@ -50,13 +50,8 @@ * @param \Drupal\locale\LocaleConfigManager $localeConfig; * The locale configuration manager object. */ - // @todo Figure out signature. public function __construct(array $definition, $name, $langcode, \Drupal\locale\LocaleConfigManager $localeConfig) { + parent::__construct($definition, $name); - // @todo parent::__construct() needs a $plugin_id and $plugin_definition, - // but not sure how to get those. - $plugin_id = ''; - $plugin_definition = array(); - parent::__construct($definition, $plugin_id, $plugin_definition, $name); $this->langcode = $langcode; $this->localeConfig = $localeConfig; } diff -u b/core/modules/text/lib/Drupal/text/TextProcessed.php b/core/modules/text/lib/Drupal/text/TextProcessed.php --- b/core/modules/text/lib/Drupal/text/TextProcessed.php +++ b/core/modules/text/lib/Drupal/text/TextProcessed.php @@ -37,8 +37,8 @@ /** * Overrides TypedData::__construct(). */ - public function __construct(array $definition, $plugin_id, array $plugin_definition, $name = NULL, TypedDataInterface $parent = NULL) { - parent::__construct($definition, $plugin_id, $plugin_definition, $name, $parent); + public function __construct(array $definition, $name = NULL, TypedDataInterface $parent = NULL) { + parent::__construct($definition, $name, $parent); if (!isset($definition['settings']['text source'])) { throw new InvalidArgumentException("The definition's 'source' key has to specify the name of the text property to be processed.");