updated core to 8.6.1 via composer
This commit is contained in:
@@ -32,7 +32,7 @@ class LinkItem extends FieldItemBase implements LinkItemInterface {
|
||||
public static function defaultFieldSettings() {
|
||||
return [
|
||||
'title' => DRUPAL_OPTIONAL,
|
||||
'link_type' => LinkItemInterface::LINK_GENERIC
|
||||
'link_type' => LinkItemInterface::LINK_GENERIC,
|
||||
] + parent::defaultFieldSettings();
|
||||
}
|
||||
|
||||
|
||||
@@ -101,7 +101,7 @@ class LinkWidget extends WidgetBase {
|
||||
*/
|
||||
protected static function getUserEnteredStringAsUri($string) {
|
||||
// By default, assume the entered string is an URI.
|
||||
$uri = $string;
|
||||
$uri = trim($string);
|
||||
|
||||
// Detect entity autocomplete string, map to 'entity:' URI.
|
||||
$entity_id = EntityAutocomplete::extractEntityIdFromAutocompleteInput($string);
|
||||
@@ -157,6 +157,17 @@ class LinkWidget extends WidgetBase {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Form element validation handler for the 'title' element.
|
||||
*
|
||||
* Requires the URL value if a link title was filled in.
|
||||
*/
|
||||
public static function validateTitleNoLink(&$element, FormStateInterface $form_state, $form) {
|
||||
if ($element['uri']['#value'] === '' && $element['title']['#value'] !== '') {
|
||||
$form_state->setError($element['uri'], t('The @uri field is required when the @title field is specified.', ['@title' => $element['title']['#title'], '@uri' => $element['uri']['#title']]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
@@ -222,8 +233,12 @@ class LinkWidget extends WidgetBase {
|
||||
// Post-process the title field to make it conditionally required if URL is
|
||||
// non-empty. Omit the validation on the field edit form, since the field
|
||||
// settings cannot be saved otherwise.
|
||||
//
|
||||
// Validate that title field is filled out (regardless of uri) when it is a
|
||||
// required field.
|
||||
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') === DRUPAL_REQUIRED) {
|
||||
$element['#element_validate'][] = [get_called_class(), 'validateTitleElement'];
|
||||
$element['#element_validate'][] = [get_called_class(), 'validateTitleNoLink'];
|
||||
|
||||
if (!$element['title']['#required']) {
|
||||
// Make title required on the front-end when URI filled-in.
|
||||
@@ -237,11 +252,17 @@ class LinkWidget extends WidgetBase {
|
||||
}
|
||||
|
||||
$element['title']['#states']['required'] = [
|
||||
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE]
|
||||
':input[name="' . $selector . '[' . $delta . '][uri]"]' => ['filled' => TRUE],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure that a URI is always entered when an optional title field is
|
||||
// submitted.
|
||||
if (!$this->isDefaultValueWidget($form_state) && $this->getFieldSetting('title') == DRUPAL_OPTIONAL) {
|
||||
$element['#element_validate'][] = [get_called_class(), 'validateTitleNoLink'];
|
||||
}
|
||||
|
||||
// Exposing the attributes array in the widget is left for alternate and more
|
||||
// advanced field widgets.
|
||||
$element['attributes'] = [
|
||||
@@ -377,7 +398,6 @@ class LinkWidget extends WidgetBase {
|
||||
return $values;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*
|
||||
|
||||
+1
-1
@@ -30,7 +30,7 @@ class LinkNotExistingInternalConstraintValidator extends ConstraintValidator {
|
||||
if ($url->isRouted()) {
|
||||
$allowed = TRUE;
|
||||
try {
|
||||
$url->toString();
|
||||
$url->toString(TRUE);
|
||||
}
|
||||
// The following exceptions are all possible during URL generation, and
|
||||
// should be considered as disallowed URLs.
|
||||
|
||||
@@ -29,8 +29,8 @@ class LinkField extends CckFieldPluginBase {
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
// See d6_field_formatter_settings.yml and CckFieldPluginBase
|
||||
// processFieldFormatter().
|
||||
// See d6_field_formatter_settings.yml and FieldPluginBase
|
||||
// alterFieldFormatterMigration().
|
||||
return [
|
||||
'default' => 'link',
|
||||
'plain' => 'link',
|
||||
|
||||
@@ -38,9 +38,9 @@ class LinkField extends D6LinkField {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
* @inheritdoc}
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration) {
|
||||
public function alterFieldInstanceMigration(MigrationInterface $migration) {
|
||||
$process = [
|
||||
'plugin' => 'static_map',
|
||||
'source' => 'settings/title',
|
||||
|
||||
@@ -23,7 +23,7 @@ class LinkField extends FieldPluginBase {
|
||||
*/
|
||||
public function getFieldFormatterMap() {
|
||||
// See d6_field_formatter_settings.yml and FieldPluginBase
|
||||
// processFieldFormatter().
|
||||
// alterFieldFormatterMigration().
|
||||
return [
|
||||
'default' => 'link',
|
||||
'plain' => 'link',
|
||||
@@ -39,7 +39,7 @@ class LinkField extends FieldPluginBase {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldValues(MigrationInterface $migration, $field_name, $data) {
|
||||
public function defineValueProcessPipeline(MigrationInterface $migration, $field_name, $data) {
|
||||
$process = [
|
||||
'plugin' => 'field_link',
|
||||
'source' => $field_name,
|
||||
|
||||
@@ -42,7 +42,7 @@ class LinkField extends D6LinkField {
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function processFieldInstance(MigrationInterface $migration) {
|
||||
public function alterFieldInstanceMigration(MigrationInterface $migration) {
|
||||
$process = [
|
||||
'plugin' => 'static_map',
|
||||
'source' => 'settings/title',
|
||||
|
||||
@@ -45,7 +45,7 @@ class LinkViewsTokensTest extends ViewTestBase {
|
||||
// Create Basic page node type.
|
||||
$this->drupalCreateContentType([
|
||||
'type' => 'page',
|
||||
'name' => 'Basic page'
|
||||
'name' => 'Basic page',
|
||||
]);
|
||||
|
||||
// Create a field.
|
||||
|
||||
Reference in New Issue
Block a user