Commit 12f895ec authored by webchick's avatar webchick
Browse files

Issue #2132145 by plopesc, amateescu, Xano: Rename 'typed_data' /...

Issue #2132145 by plopesc, amateescu, Xano: Rename 'typed_data' / Drupal::typedData() to 'typed_data_manager' / Drupal::typedDataManager.
parent 8aab1a03
......@@ -248,7 +248,7 @@ services:
factory_class: Drupal\Core\Database\Database
factory_method: getConnection
arguments: [slave]
typed_data:
typed_data_manager:
class: Drupal\Core\TypedData\TypedDataManager
parent: default_plugin_manager
calls:
......
......@@ -366,8 +366,8 @@ public static function moduleHandler() {
*
* @see \Drupal\Core\TypedData\TypedDataManager::create()
*/
public static function typedData() {
return static::$container->get('typed_data');
public static function typedDataManager() {
return static::$container->get('typed_data_manager');
}
/**
......
......@@ -261,7 +261,7 @@ public function getString() {
*/
public function validate() {
// @todo: Add the typed data manager as proper dependency.
return \Drupal::typedData()->getValidator()->validate($this);
return \Drupal::typedDataManager()->getValidator()->validate($this);
}
/**
......@@ -414,7 +414,7 @@ protected function getTranslatedField($name, $langcode) {
if (isset($this->values[$name][$langcode])) {
$value = $this->values[$name][$langcode];
}
$field = \Drupal::typedData()->getPropertyInstance($this, $name, $value);
$field = \Drupal::typedDataManager()->getPropertyInstance($this, $name, $value);
if ($default) {
// $this->defaultLangcode might not be set if we are initializing the
// default language code cache, in which case there is no valid
......
......@@ -266,7 +266,7 @@ public function onBundleDelete($bundle) { }
*/
public function onFieldItemsPurge(EntityInterface $entity, FieldInstanceInterface $instance) {
if ($values = $this->readFieldItemsToPurge($entity, $instance)) {
$items = \Drupal::typedData()->create($instance, $values, $instance->getName(), $entity);
$items = \Drupal::typedDataManager()->create($instance, $values, $instance->getName(), $entity);
$items->delete();
}
$this->purgeFieldItems($entity, $instance);
......
......@@ -95,7 +95,7 @@ public function getConfig() {
*/
public function setConfig($key, $value) {
if ($definition = $this->getConfigDefinition($key)) {
$typed_data = \Drupal::typedData()->create($definition, $value);
$typed_data = \Drupal::typedDataManager()->create($definition, $value);
if ($typed_data->validate()->count() > 0) {
throw new PluginException("The provided configuration value does not pass validation.");
......
......@@ -66,7 +66,7 @@ public function getConstraints() {
// widgets.
$cardinality = $this->getFieldDefinition()->getCardinality();
if ($cardinality != FieldDefinitionInterface::CARDINALITY_UNLIMITED) {
$constraints[] = \Drupal::typedData()
$constraints[] = \Drupal::typedDataManager()
->getValidationConstraintManager()
->create('Count', array(
'max' => $cardinality,
......
......@@ -108,7 +108,7 @@ public function setSetting($setting_name, $value) {
* {@inheritdoc}
*/
public function getPropertyNames() {
return array_keys(\Drupal::typedData()->create($this->getItemDefinition())->getPropertyDefinitions());
return array_keys(\Drupal::typedDataManager()->create($this->getItemDefinition())->getPropertyDefinitions());
}
/**
......
......@@ -32,7 +32,7 @@ public function __construct(DataDefinitionInterface $definition, $name = NULL, T
// with the whole item.
foreach ($this->getPropertyDefinitions() as $name => $definition) {
if ($definition->isComputed()) {
$this->properties[$name] = \Drupal::typedData()->getPropertyInstance($this, $name);
$this->properties[$name] = \Drupal::typedDataManager()->getPropertyInstance($this, $name);
}
}
}
......
......@@ -46,7 +46,7 @@ public function getContextValue() {
public function setContextValue($value) {
// Make sure the value set is a typed data object.
if (!empty($this->contextDefinition['type']) && !$value instanceof TypedDataInterface) {
$value = \Drupal::typedData()->create(new DataDefinition($this->contextDefinition), $value);
$value = \Drupal::typedDataManager()->create(new DataDefinition($this->contextDefinition), $value);
}
parent::setContextValue($value);
}
......
......@@ -28,7 +28,7 @@
* type, is ordered and may contain duplicates. The class used for a list of
* items of a certain type may be specified using the 'list class' key.
*
* @see \Drupal::typedData()
* @see \Drupal::typedDataManager()
* @see \Drupal\Core\TypedData\TypedDataManager::create()
* @see hook_data_type_info_alter()
*
......
......@@ -43,7 +43,7 @@ public function getValue() {
* {@inheritdoc}
*/
public function setValue($value, $notify = TRUE) {
$this->target = \Drupal::typedData()->create($this->getTargetDefinition(), $value);
$this->target = \Drupal::typedDataManager()->create($this->getTargetDefinition(), $value);
// Notify the parent of any changes.
if ($notify && isset($this->parent)) {
$this->parent->onChange($this->name);
......
......@@ -69,7 +69,7 @@ public function getClass() {
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::typedData()
$item_type_definition = \Drupal::typedDataManager()
->getDefinition($this->getItemDefinition()->getDataType());
return $item_type_definition['list_class'];
}
......
......@@ -137,7 +137,7 @@ public function offsetGet($offset) {
* @return \Drupal\Core\TypedData\TypedDataInterface
*/
protected function createItem($offset = 0, $value = NULL) {
return \Drupal::typedData()->getPropertyInstance($this, $offset, $value);
return \Drupal::typedDataManager()->getPropertyInstance($this, $offset, $value);
}
/**
......
......@@ -119,7 +119,7 @@ public function get($property_name) {
$value = $this->values[$property_name];
}
// If the property is unknown, this will throw an exception.
$this->properties[$property_name] = \Drupal::typedData()->getPropertyInstance($this, $property_name, $value);
$this->properties[$property_name] = \Drupal::typedDataManager()->getPropertyInstance($this, $property_name, $value);
}
return $this->properties[$property_name];
}
......
......@@ -73,7 +73,7 @@ public function getPluginId() {
* {@inheritdoc}
*/
public function getPluginDefinition() {
return \Drupal::typedData()->getDefinition($this->definition->getDataType());
return \Drupal::typedDataManager()->getDefinition($this->definition->getDataType());
}
/**
......@@ -113,7 +113,7 @@ public function getString() {
*/
public function getConstraints() {
// @todo: Add the typed data manager as proper dependency.
return \Drupal::typedData()->getConstraints($this->definition);
return \Drupal::typedDataManager()->getConstraints($this->definition);
}
/**
......@@ -121,7 +121,7 @@ public function getConstraints() {
*/
public function validate() {
// @todo: Add the typed data manager as proper dependency.
return \Drupal::typedData()->getValidator()->validate($this);
return \Drupal::typedDataManager()->getValidator()->validate($this);
}
/**
......
......@@ -109,7 +109,7 @@ public function createInstance($data_type, array $configuration) {
* @return \Drupal\Core\TypedData\TypedDataInterface
* The instantiated typed data object.
*
* @see \Drupal::typedData()
* @see \Drupal::typedDataManager()
* @see \Drupal\Core\TypedData\TypedDataManager::getPropertyInstance()
* @see \Drupal\Core\TypedData\Plugin\DataType\Integer
* @see \Drupal\Core\TypedData\Plugin\DataType\Float
......
......@@ -49,7 +49,7 @@ public static function schema(FieldInterface $field) {
* {@inheritdoc}
*/
public function getConstraints() {
$constraint_manager = \Drupal::typedData()->getValidationConstraintManager();
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager->create('ComplexData', array(
......
......@@ -36,7 +36,7 @@ function field_info_cache_clear() {
entity_info_cache_clear();
// Clear typed data definitions.
\Drupal::typedData()->clearCachedDefinitions();
\Drupal::typedDataManager()->clearCachedDefinitions();
\Drupal::service('plugin.manager.field.field_type')->clearCachedDefinitions();
\Drupal::service('config.factory')->reset();
......
......@@ -128,7 +128,7 @@ public function delete() {
* {@inheritdoc}
*/
public function getConstraints() {
$constraint_manager = \Drupal::typedData()->getValidationConstraintManager();
$constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager();
$constraints = parent::getConstraints();
$constraints[] = $constraint_manager->create('ComplexData', array(
......
......@@ -46,7 +46,7 @@ class FieldEditForm extends FormBase {
*
* @var \Drupal\Core\TypedData\TypedDataManager
*/
protected $typedData;
protected $typedDataManager;
/**
* {@inheritdoc}
......@@ -62,13 +62,13 @@ public function getFormId() {
* The entity manager.
* @param \Drupal\field\FieldInfo $field_info
* The field info service.
* @param \Drupal\Core\TypedData\TypedDataManager $typed_data
* @param \Drupal\Core\TypedData\TypedDataManager $typed_data_manager
* The typed data manager.
*/
public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, TypedDataManager $typed_data) {
public function __construct(EntityManagerInterface $entity_manager, FieldInfo $field_info, TypedDataManager $typed_data_manager) {
$this->entityManager = $entity_manager;
$this->fieldInfo = $field_info;
$this->typedData = $typed_data;
$this->typedDataManager = $typed_data_manager;
}
/**
......@@ -78,7 +78,7 @@ public static function create(ContainerInterface $container) {
return new static(
$container->get('entity.manager'),
$container->get('field.info'),
$container->get('typed_data')
$container->get('typed_data_manager')
);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment