Update to Drupal 8.2.0. For more information, see https://www.drupal.org/project/drupal/releases/8.2.0

This commit is contained in:
Pantheon Automation 2016-10-06 15:16:20 -07:00 committed by Greg Anderson
parent 2f563ab520
commit f1c8716f57
1732 changed files with 52334 additions and 11780 deletions

View file

@ -105,22 +105,17 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface {
* {@inheritdoc}
*/
public static function baseFieldDefinitions(EntityTypeInterface $entity_type) {
$fields['id'] = BaseFieldDefinition::create('integer')
->setLabel(t('ID'))
->setDescription(t('The ID of the shortcut.'))
->setReadOnly(TRUE)
->setSetting('unsigned', TRUE);
/** @var \Drupal\Core\Field\BaseFieldDefinition[] $fields */
$fields = parent::baseFieldDefinitions($entity_type);
$fields['uuid'] = BaseFieldDefinition::create('uuid')
->setLabel(t('UUID'))
->setDescription(t('The UUID of the shortcut.'))
->setReadOnly(TRUE);
$fields['id']->setDescription(t('The ID of the shortcut.'));
$fields['shortcut_set'] = BaseFieldDefinition::create('entity_reference')
->setLabel(t('Shortcut set'))
->setDescription(t('The bundle of the shortcut.'))
->setSetting('target_type', 'shortcut_set')
->setRequired(TRUE);
$fields['uuid']->setDescription(t('The UUID of the shortcut.'));
$fields['shortcut_set']->setLabel(t('Shortcut set'))
->setDescription(t('The bundle of the shortcut.'));
$fields['langcode']->setDescription(t('The language code of the shortcut.'));
$fields['title'] = BaseFieldDefinition::create('string')
->setLabel(t('Name'))
@ -154,18 +149,6 @@ class Shortcut extends ContentEntityBase implements ShortcutInterface {
))
->setDisplayConfigurable('form', TRUE);
$fields['langcode'] = BaseFieldDefinition::create('language')
->setLabel(t('Language'))
->setDescription(t('The language code of the shortcut.'))
->setTranslatable(TRUE)
->setDisplayOptions('view', array(
'type' => 'hidden',
))
->setDisplayOptions('form', array(
'type' => 'language_select',
'weight' => 2,
));
return $fields;
}

View file

@ -88,7 +88,7 @@ class SetCustomize extends EntityForm {
return array(
'submit' => array(
'#type' => 'submit',
'#value' => t('Save changes'),
'#value' => t('Save'),
'#access' => (bool) Element::getVisibleChildren($form['shortcuts']['links']),
'#submit' => array('::submitForm', '::save'),
),

View file

@ -70,6 +70,6 @@ class ShortcutSetDeleteForm extends EntityDeleteForm {
);
return parent::buildForm($form, $form_state);
}
}
}

View file

@ -23,12 +23,22 @@ class ShortcutForm extends ContentEntityForm {
public function save(array $form, FormStateInterface $form_state) {
$entity = $this->entity;
$status = $entity->save();
if ($status == SAVED_UPDATED) {
$message = $this->t('The shortcut %link has been updated.', array('%link' => $entity->getTitle()));
$url = $entity->getUrl();
// There's an edge case where a user can have permission to
// 'link to any content', but has no right to access the linked page. So we
// check the access before showing the link.
if ($url->access()) {
$view_link = \Drupal::l($entity->getTitle(), $url);
}
else {
$message = $this->t('Added a shortcut for %title.', array('%title' => $entity->getTitle()));
$view_link = $entity->getTitle();
}
if ($status == SAVED_UPDATED) {
$message = $this->t('The shortcut %link has been updated.', array('%link' => $view_link));
}
else {
$message = $this->t('Added a shortcut for %title.', array('%title' => $view_link));
}
drupal_set_message($message);

View file

@ -46,7 +46,7 @@ interface ShortcutSetStorageInterface extends ConfigEntityStorageInterface {
/**
* Get the name of the set assigned to this user.
*
* @param \Drupal\user\Entity\User
* @param \Drupal\user\Entity\User $account
* The user account.
*
* @return string

View file

@ -6,6 +6,7 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Url;
use Drupal\shortcut\Entity\Shortcut;
use Drupal\shortcut\Entity\ShortcutSet;
use Drupal\views\Entity\View;
/**
* Create, view, edit, delete, and change shortcut links.
@ -233,7 +234,7 @@ class ShortcutLinksTest extends ShortcutTestBase {
$this->drupalGet('admin/content');
$this->assertResponse(200);
// Disable the view.
entity_load('view', 'content')->disable()->save();
View::load('content')->disable()->save();
/** @var \Drupal\Core\Routing\RouteBuilderInterface $router_builder */
$router_builder = \Drupal::service('router.builder');
$router_builder->rebuildIfNeeded();

View file

@ -88,7 +88,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
$weight--;
}
$this->drupalPostForm(NULL, $edit, t('Save changes'));
$this->drupalPostForm(NULL, $edit, t('Save'));
$this->assertRaw(t('The shortcut set has been updated.'));
\Drupal::entityManager()->getStorage('shortcut')->resetCache();

View file

@ -65,7 +65,10 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
protected function doTestBasicTranslation() {
parent::doTestBasicTranslation();
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
foreach ($this->langcodes as $langcode) {
if ($entity->hasTranslation($langcode)) {
$language = new Language(array('id' => $langcode));
@ -84,7 +87,10 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
* {@inheritdoc}
*/
protected function doTestTranslationEdit() {
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$languages = $this->container->get('language_manager')->getLanguages();
foreach ($this->langcodes as $langcode) {
@ -107,7 +113,10 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
* Tests the basic translation workflow.
*/
protected function doTestTranslationChanged() {
$entity = entity_load($this->entityTypeId, $this->entityId, TRUE);
$storage = $this->container->get('entity_type.manager')
->getStorage($this->entityTypeId);
$storage->resetCache([$this->entityId]);
$entity = $storage->load($this->entityId);
$this->assertFalse(
$entity instanceof EntityChangedInterface,