diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php index 35f8b2f..916c3df 100644 --- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php +++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php @@ -177,18 +177,18 @@ protected function buildEntity(array $form, array &$form_state) { $entity = clone $form_state['entity']; $field_name = $form_state['field_name']; - $field = $entity->getNGEntity()->get($field_name); - if ($field->getFieldDefinition() instanceof FieldInstanceInterface) { + $items = $entity->get($field_name); + if ($items->getFieldDefinition() instanceof FieldInstanceInterface) { field_attach_extract_form_values($entity, $form, $form_state, array('field_name' => $field_name)); } else { - \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($field, $form, $form_state, $form_state['langcode']); + \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($items, $form, $form_state); } // @todo Refine automated log messages and abstract them to all entity // types: http://drupal.org/node/1678002. if ($entity->entityType() == 'node' && $entity->isNewRevision() && !isset($entity->log)) { - $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $field->getFieldDefinition()->getFieldLabel())); + $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $items->getFieldDefinition()->getFieldLabel())); } return $entity; diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php index 5e4bb6b..c614133 100644 --- a/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php +++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Widget/WidgetPluginManager.php @@ -11,6 +11,7 @@ use Drupal\Component\Plugin\PluginManagerBase; use Drupal\Component\Plugin\Discovery\ProcessDecorator; use Drupal\Core\Cache\CacheBackendInterface; +use Drupal\Core\Entity\Field\FieldItemListInterface; use Drupal\Core\Entity\Field\FieldTypePluginManager; use Drupal\Core\Extension\ModuleHandlerInterface; use Drupal\Core\Language\LanguageManager; @@ -214,7 +215,7 @@ public function getDefaultSettings($type) { /** * @todo Document. */ - public function baseFieldForm(FieldInterface $field, array &$form, array &$form_state, $langcode) { + public function baseFieldForm(FieldItemListInterface $field, array &$form, array &$form_state) { $options = array( 'field_definition' => $field->getFieldDefinition(), 'form_mode' => 'default', @@ -225,18 +226,16 @@ public function baseFieldForm(FieldInterface $field, array &$form, array &$form_ } $widget = $this->getInstance($options); - $entity = $field->getParent()->getBCEntity(); - $form += array('#parents' => array()); - $result = $widget->form($entity, $langcode, $field, $form, $form_state); - $field_name = $field->getName(); + $result = $widget->form($field, $form, $form_state); + $field_name = $field->getFieldDefinition()->getFieldName(); return isset($result[$field_name]) ? $result[$field_name] : array(); } /** * @todo Document. */ - public function baseFieldExtractFormValues(FieldInterface $field, array &$form, array &$form_state, $langcode) { + public function baseFieldExtractFormValues(FieldItemListInterfaceInterface $field, array &$form, array &$form_state) { $options = array( 'field_definition' => $field->getFieldDefinition(), 'form_mode' => 'default', @@ -247,9 +246,7 @@ public function baseFieldExtractFormValues(FieldInterface $field, array &$form, } $widget = $this->getInstance($options); - $entity = $field->getParent()->getBCEntity(); - - $widget->extractFormValues($entity, $langcode, $field, $form, $form_state); + $widget->extractFormValues($field, $form, $form_state); } } diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php index cb7516e..a82af35 100644 --- a/core/modules/node/lib/Drupal/node/NodeFormController.php +++ b/core/modules/node/lib/Drupal/node/NodeFormController.php @@ -447,7 +447,7 @@ public function buildEntity(array $form, array &$form_state) { else { $node->setCreatedTime(REQUEST_TIME); } - \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($node->title, $form, $form_state, $this->getFormLangcode($form_state)); + \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($node->title, $form, $form_state); return $node; } diff --git a/core/modules/node/lib/Drupal/node/Plugin/field/widget/TitleWidget.php b/core/modules/node/lib/Drupal/node/Plugin/field/widget/TitleWidget.php index cd4702a..43cfd81 100644 --- a/core/modules/node/lib/Drupal/node/Plugin/field/widget/TitleWidget.php +++ b/core/modules/node/lib/Drupal/node/Plugin/field/widget/TitleWidget.php @@ -7,6 +7,7 @@ namespace Drupal\node\Plugin\field\widget; +use Drupal\Core\Entity\Field\FieldItemListInterface; use Drupal\field\Annotation\FieldWidget; use Drupal\Component\Utility\NestedArray; use Drupal\Core\Annotation\Translation; @@ -31,9 +32,11 @@ class TitleWidget extends WidgetBase { /** * {@inheritdoc} */ - public function form(EntityInterface $entity, $langcode, FieldInterface $items, array &$form, array &$form_state, $get_delta = NULL) { + public function form(FieldItemListInterface $items, array &$form, array &$form_state, $get_delta = NULL) { $field_name = $this->fieldDefinition->getFieldName(); + $entity = $items->getEntity(); + // @todo Make EntityManager::getFieldDefinitions() allow for per-bundle // definitions of base fields, so that here, we could just call // $this->fieldDefinition->getFieldLabel() instead. @@ -58,7 +61,7 @@ public function form(EntityInterface $entity, $langcode, FieldInterface $items, /** * {@inheritdoc} */ - public function extractFormValues(EntityInterface $entity, $langcode, FieldInterface $items, array $form, array &$form_state) { + public function extractFormValues(FieldItemListInterface $items, array $form, array &$form_state) { $field_name = $this->fieldDefinition->getFieldName(); // Extract the values from $form_state['values']. @@ -74,7 +77,7 @@ public function extractFormValues(EntityInterface $entity, $langcode, FieldInter /** * {@inheritdoc} */ - public function formElement(FieldInterface $items, $delta, array $element, $langcode, array &$form, array &$form_state) { + public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) { return array(); } }