diff --git a/core/lib/Drupal/Core/Entity/Field/FieldItemList.php b/core/lib/Drupal/Core/Entity/Field/FieldItemList.php
index 4b4e1eb..545768a 100644
--- a/core/lib/Drupal/Core/Entity/Field/FieldItemList.php
+++ b/core/lib/Drupal/Core/Entity/Field/FieldItemList.php
@@ -8,6 +8,7 @@
namespace Drupal\Core\Entity\Field;
use Drupal\Core\Entity\Field\FieldItemListInterface;
+use Drupal\Core\Entity\Field\FieldDefinition;
use Drupal\Core\Session\AccountInterface;
use Drupal\Core\TypedData\TypedDataInterface;
use Drupal\Core\TypedData\ItemList;
diff --git a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/FieldItemDeriver.php b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/FieldItemDeriver.php
index 60b47f9..4c1d1d1 100644
--- a/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/FieldItemDeriver.php
+++ b/core/lib/Drupal/Core/Entity/Plugin/DataType/Deriver/FieldItemDeriver.php
@@ -77,6 +77,16 @@ public function getDerivativeDefinition($derivative_id, array $base_plugin_defin
*/
public function getDerivativeDefinitions(array $base_plugin_definition) {
foreach ($this->fieldTypePluginManager->getDefinitions() as $plugin_id => $definition) {
+ // Provide easy access to the field type without requiring consuming code
+ // to parse it from the full data type.
+ $definition['field_type'] = $plugin_id;
+
+ // The distinction between 'settings' and 'instance_settings' is only
+ // meaningful at the field type plugin level. At the Typed data API level,
+ // merge them.
+ $definition['settings'] = $definition['instance_settings'] + $definition['settings'];
+ unset($definition['instance_settings']);
+
$this->derivatives[$plugin_id] = $definition;
}
return $this->derivatives;
diff --git a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
index 7ad2cfd..32178bf 100644
--- a/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
+++ b/core/lib/Drupal/Core/Validation/Plugin/Validation/Constraint/AllowedValuesConstraintValidator.php
@@ -20,6 +20,9 @@ class AllowedValuesConstraintValidator extends ChoiceValidator {
* {@inheritdoc}
*/
public function validate($value, Constraint $constraint) {
+ if (!isset($value)) {
+ return;
+ }
if ($this->context->getMetadata()->getTypedData() instanceof AllowedValuesInterface) {
$account = \Drupal::currentUser();
$allowed_values = $this->context->getMetadata()->getTypedData()->getSettableValues($account);
diff --git a/core/modules/edit/js/editors/directEditor.js b/core/modules/edit/js/editors/directEditor.js
index 5fed240..59bb6d8 100644
--- a/core/modules/edit/js/editors/directEditor.js
+++ b/core/modules/edit/js/editors/directEditor.js
@@ -21,7 +21,13 @@ Drupal.edit.editors.direct = Drupal.edit.EditorView.extend({
var fieldModel = this.fieldModel;
// Store the original value of this field. Necessary for reverting changes.
- var $textElement = this.$textElement = this.$el.find('.field-item:first');
+ var $textElement;
+ if (this.$el.is(':has(.field-item)')) {
+ $textElement = this.$textElement = this.$el.find('.field-item:first');
+ }
+ else {
+ $textElement = this.$textElement = this.$el;
+ }
editorModel.set('originalValue', $.trim(this.$textElement.text()));
// Sets the state to 'changed' whenever the value changes
diff --git a/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php b/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
index ddecebf..9d442e4 100644
--- a/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
+++ b/core/modules/edit/lib/Drupal/edit/Access/EditEntityFieldAccessCheck.php
@@ -94,13 +94,16 @@ protected function validateAndUpcastRequestAttributes(Request $request) {
// Validate the field name and language.
$field_name = $request->attributes->get('field_name');
- if (!$field_name || !$this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $field_name)) {
+ if (!$field_name) {
throw new NotFoundHttpException();
}
$langcode = $request->attributes->get('langcode');
if (!$langcode || (field_valid_language($langcode) !== $langcode)) {
throw new NotFoundHttpException();
}
+ if (!($field_definition = $entity->getTranslation($langcode)->get($field_name)->getFieldDefinition())) {
+ throw new NotFoundHttpException();
+ }
}
}
diff --git a/core/modules/edit/lib/Drupal/edit/EditController.php b/core/modules/edit/lib/Drupal/edit/EditController.php
index 433bfe7..e422872 100644
--- a/core/modules/edit/lib/Drupal/edit/EditController.php
+++ b/core/modules/edit/lib/Drupal/edit/EditController.php
@@ -26,6 +26,7 @@
use Drupal\edit\Ajax\MetadataCommand;
use Drupal\edit\Form\EditFieldForm;
use Drupal\user\TempStoreFactory;
+use Drupal\field\FieldInstanceInterface;
/**
* Returns responses for Edit module routes.
@@ -133,12 +134,15 @@ public function metadata(Request $request) {
}
// Validate the field name and language.
- if (!$field_name || !($instance = $this->fieldInfo->getInstance($entity->entityType(), $entity->bundle(), $field_name))) {
+ if (!$field_name) {
throw new NotFoundHttpException();
}
if (!$langcode || (field_valid_language($langcode) !== $langcode)) {
throw new NotFoundHttpException();
}
+ if (!($field_definition = $entity->getTranslation($langcode)->get($field_name)->getFieldDefinition())) {
+ throw new NotFoundHttpException();
+ }
// If the entity information for this field is requested, include it.
$entity_id = $entity->entityType() . '/' . $entity_id;
@@ -146,7 +150,7 @@ public function metadata(Request $request) {
$metadata[$entity_id] = $this->metadataGenerator->generateEntity($entity, $langcode);
}
- $metadata[$field] = $this->metadataGenerator->generateField($entity, $instance, $langcode, $view_mode);
+ $metadata[$field] = $this->metadataGenerator->generateField($entity, $field_definition, $langcode, $view_mode);
}
return new JsonResponse($metadata);
@@ -216,7 +220,14 @@ public function fieldForm(EntityInterface $entity, $field_name, $langcode, $view
// The form submission saved the entity in tempstore. Return the
// updated view of the field from the tempstore copy.
$entity = $this->tempStoreFactory->get('edit')->get($entity->uuid());
- $output = field_view_field($entity, $field_name, $view_mode_id, $langcode);
+
+ $field = $entity->get($field_name);
+ if ($field->getFieldDefinition() instanceof FieldInstanceInterface) {
+ $output = field_view_field($entity, $field_name, $view_mode_id, $langcode);
+ }
+ else {
+ $output = \Drupal::service('plugin.manager.field.formatter')->viewBaseField($field);
+ }
$response->addCommand(new FieldFormSavedCommand(drupal_render($output)));
}
diff --git a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
index 6a75527..35f8b2f 100644
--- a/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
+++ b/core/modules/edit/lib/Drupal/edit/Form/EditFieldForm.php
@@ -14,6 +14,7 @@
use Drupal\Core\Extension\ModuleHandlerInterface;
use Drupal\Core\Form\FormInterface;
use Drupal\user\TempStoreFactory;
+use Drupal\field\FieldInstanceInterface;
/**
* Builds and process a form for editing a single entity field.
@@ -86,7 +87,13 @@ public function buildForm(array $form, array &$form_state, EntityInterface $enti
}
// Add the field form.
- field_attach_form($form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' => $form_state['field_name']));
+ $field = $entity->get($field_name);
+ if ($field->getFieldDefinition() instanceof FieldInstanceInterface) {
+ field_attach_form($form_state['entity'], $form, $form_state, $form_state['langcode'], array('field_name' => $form_state['field_name']));
+ }
+ else {
+ $form[$field_name] = \Drupal::service('plugin.manager.field.widget')->baseFieldForm($field, $form, $form_state, $form_state['langcode']);
+ }
// Add a submit button. Give it a class for easy JavaScript targeting.
$form['actions'] = array('#type' => 'actions');
@@ -138,7 +145,14 @@ protected function init(array &$form_state, EntityInterface $entity, $field_name
*/
public function validateForm(array &$form, array &$form_state) {
$entity = $this->buildEntity($form, $form_state);
- field_attach_form_validate($entity, $form, $form_state, array('field_name' => $form_state['field_name']));
+ $field_name = $form_state['field_name'];
+ $field = $entity->get($field_name);
+ if ($field->getFieldDefinition() instanceof FieldInstanceInterface) {
+ field_attach_form_validate($entity, $form, $form_state, array('field_name' => $field_name));
+ }
+ else {
+ // @todo
+ }
}
/**
@@ -162,13 +176,19 @@ public function submitForm(array &$form, array &$form_state) {
protected function buildEntity(array $form, array &$form_state) {
$entity = clone $form_state['entity'];
- field_attach_extract_form_values($entity, $form, $form_state, array('field_name' => $form_state['field_name']));
+ $field_name = $form_state['field_name'];
+ $field = $entity->getNGEntity()->get($field_name);
+ if ($field->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']);
+ }
// @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)) {
- $instance = field_info_instance($entity->entityType(), $form_state['field_name'], $entity->bundle());
- $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $instance['label']));
+ $entity->log = t('Updated the %field-name field through in-place editing.', array('%field-name' => $field->getFieldDefinition()->getFieldLabel()));
}
return $entity;
diff --git a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
index 74d13f9..279019e 100644
--- a/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
+++ b/core/modules/edit/lib/Drupal/edit/MetadataGenerator.php
@@ -77,7 +77,13 @@ public function generateField(EntityInterface $entity, FieldDefinitionInterface
}
// Early-return if no editor is available.
- $formatter_id = entity_get_render_display($entity, $view_mode)->getRenderer($field_name)->getPluginId();
+ if ($field_definition instanceof FieldInstanceInterface) {
+ $formatter_id = entity_get_render_display($entity, $view_mode)->getRenderer($field_name)->getPluginId();
+ }
+ else {
+ $field_type_info = field_info_field_types($field_definition->getFieldType());
+ $formatter_id = $field_type_info['default_formatter'];
+ }
$items = $entity->getTranslation($langcode)->get($field_name)->getValue();
$editor_id = $this->editorSelector->getEditor($formatter_id, $field_definition, $items);
if (!isset($editor_id)) {
diff --git a/core/modules/field/field.module b/core/modules/field/field.module
index 7ec7738..4e8af1a 100644
--- a/core/modules/field/field.module
+++ b/core/modules/field/field.module
@@ -153,6 +153,9 @@ function field_theme() {
'field' => array(
'render element' => 'element',
),
+ 'field__title' => array(
+ 'base hook' => 'field',
+ ),
'field_multiple_value_form' => array(
'render element' => 'element',
),
@@ -809,6 +812,13 @@ function theme_field($variables) {
}
/**
+ * @todo Document.
+ */
+function theme_field__title($variables) {
+ return '' . drupal_render($variables['items']) . '';
+}
+
+/**
* Assembles a partial entity structure with initial IDs.
*
* @param stdClass $ids
diff --git a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
index f663959..21817bb 100644
--- a/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
+++ b/core/modules/field/lib/Drupal/field/Plugin/Type/Formatter/FormatterPluginManager.php
@@ -10,6 +10,7 @@
use Drupal\Component\Plugin\PluginManagerBase;
use Drupal\Component\Plugin\Factory\DefaultFactory;
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;
@@ -17,7 +18,7 @@
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
-use Drupal\field\Entity\FieldInstance;
+use Drupal\Core\Entity\Field\FieldInterface;
/**
* Plugin type manager for field formatters.
@@ -206,4 +207,26 @@ public function getDefaultSettings($type) {
return isset($info['settings']) ? $info['settings'] : array();
}
+ /**
+ * @todo Document.
+ */
+ public function viewBaseField(FieldItemListInterface $items) {
+ $options = array(
+ 'field_definition' => $items->getFieldDefinition(),
+ 'view_mode' => 'default',
+ 'configuration' => array(
+ 'label' => 'hidden',
+ ),
+ );
+ $formatter = $this->getInstance($options);
+
+ $entity = $items->getEntity();
+
+ $items_multi = array($entity->id() => $items);
+ $formatter->prepareView($items_multi);
+ $result = $formatter->view($items);
+ $field_name = $items->getFieldDefinition()->getFieldName();
+ return isset($result[$field_name]) ? $result[$field_name] : array();
+ }
+
}
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 5559e8a..5e4bb6b 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
@@ -18,6 +18,7 @@
use Drupal\Core\Plugin\Discovery\CacheDecorator;
use Drupal\Core\Plugin\Discovery\AlterDecorator;
use Drupal\Core\Plugin\Discovery\AnnotatedClassDiscovery;
+use Drupal\Core\Entity\Field\FieldInterface;
/**
* Plugin type manager for field widgets.
@@ -210,4 +211,45 @@ public function getDefaultSettings($type) {
return isset($info['settings']) ? $info['settings'] : array();
}
+ /**
+ * @todo Document.
+ */
+ public function baseFieldForm(FieldInterface $field, array &$form, array &$form_state, $langcode) {
+ $options = array(
+ 'field_definition' => $field->getFieldDefinition(),
+ 'form_mode' => 'default',
+ 'configuration' => array(),
+ );
+ if (($field_data_definition = $field->getDefinition()) && isset($field_data_definition['default_widget'])) {
+ $options['configuration']['type'] = $field_data_definition['default_widget'];
+ }
+ $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();
+ return isset($result[$field_name]) ? $result[$field_name] : array();
+ }
+
+ /**
+ * @todo Document.
+ */
+ public function baseFieldExtractFormValues(FieldInterface $field, array &$form, array &$form_state, $langcode) {
+ $options = array(
+ 'field_definition' => $field->getFieldDefinition(),
+ 'form_mode' => 'default',
+ 'configuration' => array(),
+ );
+ if (($field_data_definition = $field->getDefinition()) && isset($field_data_definition['default_widget'])) {
+ $options['configuration']['type'] = $field_data_definition['default_widget'];
+ }
+ $widget = $this->getInstance($options);
+
+ $entity = $field->getParent()->getBCEntity();
+
+ $widget->extractFormValues($entity, $langcode, $field, $form, $form_state);
+ }
+
}
diff --git a/core/modules/node/lib/Drupal/node/Entity/Node.php b/core/modules/node/lib/Drupal/node/Entity/Node.php
index 65c137b..de99152 100644
--- a/core/modules/node/lib/Drupal/node/Entity/Node.php
+++ b/core/modules/node/lib/Drupal/node/Entity/Node.php
@@ -350,14 +350,13 @@ public static function baseFieldDefinitions($entity_type) {
$properties['title'] = array(
'label' => t('Title'),
'description' => t('The title of this node, always treated as non-markup plain text.'),
- 'type' => 'string_field',
+ 'type' => 'field_item:text',
+ 'list_class' => '\Drupal\Core\Entity\Field\FieldItemList',
'required' => TRUE,
'settings' => array(
'default_value' => '',
),
- 'property_constraints' => array(
- 'value' => array('Length' => array('max' => 255)),
- ),
+ 'default_widget' => 'node_title',
);
$properties['uid'] = array(
'label' => t('User ID'),
diff --git a/core/modules/node/lib/Drupal/node/NodeFormController.php b/core/modules/node/lib/Drupal/node/NodeFormController.php
index a787175..cb7516e 100644
--- a/core/modules/node/lib/Drupal/node/NodeFormController.php
+++ b/core/modules/node/lib/Drupal/node/NodeFormController.php
@@ -101,14 +101,8 @@ public function form(array $form, array &$form_state) {
$node_type = node_type_load($node->getType());
if ($node_type->has_title) {
- $form['title'] = array(
- '#type' => 'textfield',
- '#title' => check_plain($node_type->title_label),
- '#required' => TRUE,
- '#default_value' => $node->title->value,
- '#maxlength' => 255,
- '#weight' => -5,
- );
+ $form['title'] = \Drupal::service('plugin.manager.field.widget')->baseFieldForm($node->title, $form, $form_state, $this->getFormLangcode($form_state));
+ $form['title']['#weight'] = -5;
}
$language_configuration = module_invoke('language', 'get_default_configuration', 'node', $node->getType());
@@ -437,26 +431,26 @@ public function unpublish(array $form, array &$form_state) {
* {@inheritdoc}
*/
public function buildEntity(array $form, array &$form_state) {
- $entity = parent::buildEntity($form, $form_state);
+ $node = parent::buildEntity($form, $form_state);
// A user might assign the node author by entering a user name in the node
// form, which we then need to translate to a user ID.
if (!empty($form_state['values']['name']) && $account = user_load_by_name($form_state['values']['name'])) {
- $entity->setAuthorId($account->id());
+ $node->setAuthorId($account->id());
}
else {
- $entity->setAuthorId(0);
+ $node->setAuthorId(0);
}
if (!empty($form_state['values']['date']) && $form_state['values']['date'] instanceOf DrupalDateTime) {
- $entity->setCreatedTime($form_state['values']['date']->getTimestamp());
+ $node->setCreatedTime($form_state['values']['date']->getTimestamp());
}
else {
- $entity->setCreatedTime(REQUEST_TIME);
+ $node->setCreatedTime(REQUEST_TIME);
}
- return $entity;
+ \Drupal::service('plugin.manager.field.widget')->baseFieldExtractFormValues($node->title, $form, $form_state, $this->getFormLangcode($form_state));
+ return $node;
}
-
/**
* Overrides Drupal\Core\Entity\EntityFormController::save().
*/
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
new file mode 100644
index 0000000..cd4702a
--- /dev/null
+++ b/core/modules/node/lib/Drupal/node/Plugin/field/widget/TitleWidget.php
@@ -0,0 +1,80 @@
+fieldDefinition->getFieldName();
+
+ // @todo Make EntityManager::getFieldDefinitions() allow for per-bundle
+ // definitions of base fields, so that here, we could just call
+ // $this->fieldDefinition->getFieldLabel() instead.
+ if ($entity->entityType() == 'node' && $field_name == 'title') {
+ $node_type = node_type_load($entity->bundle());
+ $label = $node_type->title_label;
+ }
+ else {
+ $label = $this->fieldDefinition->getFieldLabel();
+ }
+
+ $addition[$field_name] = array(
+ '#type' => 'textfield',
+ '#title' => check_plain($label),
+ '#required' => $this->fieldDefinition->isFieldRequired(),
+ '#default_value' => isset($items[0]->value) ? $items[0]->value : '',
+ '#maxlength' => $this->fieldDefinition->getFieldSetting('max_length'),
+ );
+ return $addition;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function extractFormValues(EntityInterface $entity, $langcode, FieldInterface $items, array $form, array &$form_state) {
+ $field_name = $this->fieldDefinition->getFieldName();
+
+ // Extract the values from $form_state['values'].
+ $path = array_merge($form['#parents'], array($field_name));
+ $key_exists = NULL;
+ $value = NestedArray::getValue($form_state['values'], $path, $key_exists);
+
+ if ($key_exists) {
+ $items->setValue(array(array('value' => $value)));
+ }
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ public function formElement(FieldInterface $items, $delta, array $element, $langcode, array &$form, array &$form_state) {
+ return array();
+ }
+}
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
index 40015ec..9b503ff 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeTitleTest.php
@@ -60,7 +60,7 @@ function testNodeTitle() {
$this->assertEqual(current($this->xpath($xpath)), $node->label(), 'Node breadcrumb is equal to node title.', 'Node');
// Test node title in comment preview.
- $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a', array(':id' => 'node-' . $node->id()))), $node->label(), 'Node preview title is equal to node title.', 'Node');
+ $this->assertEqual(current($this->xpath('//article[@id=:id]/h2/a/span', array(':id' => 'node-' . $node->id()))), $node->label(), 'Node preview title is equal to node title.', 'Node');
// Test node title is clickable on teaser list (/node).
$this->drupalGet('node');
diff --git a/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php b/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php
index 2d3efe8..3949512 100644
--- a/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php
+++ b/core/modules/node/lib/Drupal/node/Tests/NodeValidationTest.php
@@ -54,13 +54,13 @@ public function testValidation() {
$violations = $node->validate();
$this->assertEqual(count($violations), 1, 'Violation found when title is too long.');
$this->assertEqual($violations[0]->getPropertyPath(), 'title.0.value');
- $this->assertEqual($violations[0]->getMessage(), t('This value is too long. It should have %limit characters or less.', array('%limit' => 255)));
+ $this->assertEqual($violations[0]->getMessage(), 'Title: the text may not be longer than 255 characters.');
$node->set('title', NULL);
$violations = $node->validate();
$this->assertEqual(count($violations), 1, 'Violation found when title is not set.');
$this->assertEqual($violations[0]->getPropertyPath(), 'title');
- $this->assertEqual($violations[0]->getMessage(), t('This value should not be null.'));
+ $this->assertEqual($violations[0]->getMessage(), 'This value should not be null.');
// Make the title valid again.
$node->set('title', $this->randomString());
@@ -71,6 +71,6 @@ public function testValidation() {
$violations = $node->validate();
$this->assertEqual(count($violations), 1, 'Violation found when changed date is before the last changed date.');
$this->assertEqual($violations[0]->getPropertyPath(), 'changed.0.value');
- $this->assertEqual($violations[0]->getMessage(), t('The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.'));
+ $this->assertEqual($violations[0]->getMessage(), 'The content has either been modified by another user, or you have already submitted modifications. As a result, your changes cannot be saved.');
}
}
diff --git a/core/modules/node/node.module b/core/modules/node/node.module
index 0dcda45..1466cd4 100644
--- a/core/modules/node/node.module
+++ b/core/modules/node/node.module
@@ -688,7 +688,7 @@ function template_preprocess_node(&$variables) {
$uri = $node->uri();
$variables['node_url'] = url($uri['path'], $uri['options']);
- $variables['label'] = check_plain($node->label());
+ $variables['label'] = Drupal::service('plugin.manager.field.formatter')->viewBaseField($node->get('title'));
$variables['page'] = $variables['view_mode'] == 'full' && node_is_page($node);
// Helpful $content variable for templates.
diff --git a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
index 300430a..0c232a6 100644
--- a/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
+++ b/core/modules/simpletest/lib/Drupal/simpletest/WebTestBase.php
@@ -2215,7 +2215,7 @@ protected function assertNoLinkByHref($href, $message = '', $group = 'Other') {
*/
protected function clickLink($label, $index = 0) {
$url_before = $this->getUrl();
- $urls = $this->xpath('//a[normalize-space(text())=:label]', array(':label' => $label));
+ $urls = $this->xpath('//a[normalize-space()=:label]', array(':label' => $label));
if (isset($urls[$index])) {
$url_target = $this->getAbsoluteUrl($urls[$index]['href']);
diff --git a/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php b/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php
index 262537b..6f3bd49 100644
--- a/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php
+++ b/core/modules/system/lib/Drupal/system/Tests/Plugin/ContextPluginTest.php
@@ -17,7 +17,7 @@
*/
class ContextPluginTest extends DrupalUnitTestBase {
- public static $modules = array('system', 'user', 'node', 'field');
+ public static $modules = array('system', 'user', 'node', 'field', 'filter', 'text');
public static function getInfo() {
return array(