Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663

This commit is contained in:
Greg Anderson 2015-10-08 11:40:12 -07:00
parent eb34d130a8
commit f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions

View file

@ -15,11 +15,11 @@ function link_help($route_name, RouteMatchInterface $route_match) {
case 'help.page.link':
$output = '';
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Link module allows you to create fields that contain internal or external URLs and optional link text. See the <a href="!field">Field module help</a> and the <a href="!field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href="!link_documentation">online documentation for the Link module</a>.', array('!field' => \Drupal::url('help.page', array('name' => 'field')), '!field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', '!link_documentation' => 'https://www.drupal.org/documentation/modules/link')) . '</p>';
$output .= '<p>' . t('The Link module allows you to create fields that contain internal or external URLs and optional link text. See the <a href=":field">Field module help</a> and the <a href=":field_ui">Field UI help</a> pages for general information on fields and how to create and manage them. For more information, see the <a href=":link_documentation">online documentation for the Link module</a>.', array(':field' => \Drupal::url('help.page', array('name' => 'field')), ':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#', ':link_documentation' => 'https://www.drupal.org/documentation/modules/link')) . '</p>';
$output .= '<h3>' . t('Uses') . '</h3>';
$output .= '<dl>';
$output .= '<dt>' . t('Managing and displaying link fields') . '</dt>';
$output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the link field can be configured separately. See the <a href="!field_ui">Field UI help</a> for more information on how to manage fields and their display.', array('!field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
$output .= '<dd>' . t('The <em>settings</em> and the <em>display</em> of the link field can be configured separately. See the <a href=":field_ui">Field UI help</a> for more information on how to manage fields and their display.', array(':field_ui' => (\Drupal::moduleHandler()->moduleExists('field_ui')) ? \Drupal::url('help.page', array('name' => 'field_ui')) : '#')) . '</dd>';
$output .= '<dt>' . t('Setting the allowed link type') . '</dt>';
$output .= '<dd>' . t('In the field settings you can define the allowed link type to be <em>internal links only</em>, <em>external links only</em>, or <em>both internal and external links</em>. <em>Internal links only</em> and <em>both internal and external links</em> options enable an autocomplete widget for internal links, so a user does not have to copy or remember a URL.') . '</dd>';
$output .= '<dt>' . t('Adding link text') . '</dt>';

View file

@ -176,7 +176,7 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items) {
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = array();
$entity = $items->getEntity();
$settings = $this->getSettings();
@ -189,8 +189,9 @@ class LinkFormatter extends FormatterBase implements ContainerFactoryPluginInter
// If the title field value is available, use it for the link text.
if (empty($settings['url_only']) && !empty($item->title)) {
// Unsanitized token replacement here because the entire link title
// gets auto-escaped during link generation.
$link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
// gets auto-escaped during link generation in
// \Drupal\Core\Utility\LinkGenerator::generate().
$link_title = \Drupal::token()->replace($item->title, [$entity->getEntityTypeId() => $entity], ['clear' => TRUE]);
}
// Trim the link text to the desired length.

View file

@ -42,7 +42,7 @@ class LinkSeparateFormatter extends LinkFormatter {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items) {
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = array();
$entity = $items->getEntity();
$settings = $this->getSettings();
@ -55,8 +55,9 @@ class LinkSeparateFormatter extends LinkFormatter {
// If the link text field value is available, use it for the text.
if (empty($settings['url_only']) && !empty($item->title)) {
// Unsanitized token replacement here because the entire link title
// gets auto-escaped during link generation.
$link_title = \Drupal::token()->replace($item->title, array($entity->getEntityTypeId() => $entity), array('sanitize' => FALSE, 'clear' => TRUE));
// gets auto-escaped during link generation in
// \Drupal\Core\Utility\LinkGenerator::generate().
$link_title = \Drupal::token()->replace($item->title, [$entity->getEntityTypeId() => $entity], ['clear' => TRUE]);
}
// The link_separate formatter has two titles; the link text (as in the

View file

@ -159,7 +159,9 @@ class LinkWidget extends WidgetBase {
public static function validateTitleElement(&$element, FormStateInterface $form_state, $form) {
if ($element['uri']['#value'] !== '' && $element['title']['#value'] === '') {
$element['title']['#required'] = TRUE;
$form_state->setError($element['title'], t('!name field is required.', array('!name' => $element['title']['#title'])));
// We expect the field name placeholder value to be wrapped in t() here,
// so it won't be escaped again as it's already marked safe.
$form_state->setError($element['title'], t('@name field is required.', array('@name' => $element['title']['#title'])));
}
}

View file

@ -277,14 +277,14 @@ class LinkFieldTest extends WebTestBase {
"{$field_name}[0][uri]" => 'http://www.example.com',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertText(t('@name field is required.', array('@name' => t('Link text'))));
// Verify that the link text is not required, if the URL is empty.
$edit = array(
"{$field_name}[0][uri]" => '',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
// Verify that a URL and link text meets requirements.
$this->drupalGet('entity_test/add');
@ -293,7 +293,7 @@ class LinkFieldTest extends WebTestBase {
"{$field_name}[0][title]" => 'Example',
);
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertNoText(t('!name field is required.', array('!name' => t('Link text'))));
$this->assertNoText(t('@name field is required.', array('@name' => t('Link text'))));
}
}
}
@ -389,8 +389,8 @@ class LinkFieldTest extends WebTestBase {
// Verify that the link is output according to the formatter settings.
// Not using generatePermutations(), since that leads to 32 cases, which
// would not test actual link field formatter functionality but rather
// _l() and options/attributes. Only 'url_plain' has a dependency on
// 'url_only', so we have a total of ~10 cases.
// the link generator and options/attributes. Only 'url_plain' has a
// dependency on 'url_only', so we have a total of ~10 cases.
$options = array(
'trim_length' => array(NULL, 6),
'rel' => array(NULL, 'nofollow'),

View file

@ -5,7 +5,7 @@
* Contains \Drupal\Tests\link\Plugin\Validation\Constraint\LinkAccessConstraintValidatorTest.
*/
namespace Drupal\Tests\link\Plugin\Validation\Constraint;
namespace Drupal\Tests\link\Unit\Plugin\Validation\Constraint;
use Drupal\Core\Url;
use Drupal\link\Plugin\Validation\Constraint\LinkAccessConstraint;

View file

@ -5,7 +5,7 @@
* Contains \Drupal\Tests\link\Plugin\Validation\Constraint\LinkExternalProtocolsConstraintValidatorTest.
*/
namespace Drupal\Tests\link\Plugin\Validation\Constraint;
namespace Drupal\Tests\link\Unit\Plugin\Validation\Constraint;
use Drupal\Component\Utility\UrlHelper;
use Drupal\Core\Url;

View file

@ -5,7 +5,7 @@
* Contains \Drupal\Tests\link\Plugin\Validation\Constraint\LinkNotExistingInternalConstraintValidatorTest.
*/
namespace Drupal\Tests\link\Plugin\Validation\Constraint;
namespace Drupal\Tests\link\Unit\Plugin\Validation\Constraint;
use Drupal\Core\DependencyInjection\ContainerBuilder;
use Drupal\Core\Url;