Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
@ -1,2 +1,5 @@
|
|||
langcode: en
|
||||
status: true
|
||||
dependencies: { }
|
||||
id: default
|
||||
label: Default
|
||||
|
|
26
core/modules/shortcut/migration_templates/d7_shortcut.yml
Normal file
26
core/modules/shortcut/migration_templates/d7_shortcut.yml
Normal file
|
@ -0,0 +1,26 @@
|
|||
id: d7_shortcut
|
||||
label: Shortcut links
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_shortcut
|
||||
constants:
|
||||
uri_scheme: 'internal:/'
|
||||
process:
|
||||
shortcut_set:
|
||||
plugin: migration
|
||||
migration: d7_shortcut_set
|
||||
source: menu_name
|
||||
title: link_title
|
||||
weight: weight
|
||||
link:
|
||||
plugin: concat
|
||||
source:
|
||||
- 'constants/uri_scheme'
|
||||
- link_path
|
||||
destination:
|
||||
plugin: entity:shortcut
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_shortcut_set
|
||||
- d7_menu_links
|
|
@ -0,0 +1,20 @@
|
|||
id: d7_shortcut_set
|
||||
label: Shortcut sets
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_shortcut_set
|
||||
process:
|
||||
id:
|
||||
-
|
||||
plugin: static_map
|
||||
bypass: true
|
||||
source: set_name
|
||||
map:
|
||||
shortcut-set-1: default
|
||||
-
|
||||
plugin: machine_name
|
||||
field: id
|
||||
label: title
|
||||
destination:
|
||||
plugin: entity:shortcut_set
|
|
@ -0,0 +1,25 @@
|
|||
id: d7_shortcut_set_users
|
||||
label: Shortcut set user mapping
|
||||
migration_tags:
|
||||
- Drupal 7
|
||||
source:
|
||||
plugin: d7_shortcut_set_users
|
||||
process:
|
||||
uid:
|
||||
-
|
||||
plugin: migration
|
||||
migration: d7_user
|
||||
source: uid
|
||||
-
|
||||
plugin: skip_on_empty
|
||||
method: row
|
||||
set_name:
|
||||
plugin: migration
|
||||
migration: d7_shortcut_set
|
||||
source: set_name
|
||||
destination:
|
||||
plugin: shortcut_set_users
|
||||
migration_dependencies:
|
||||
required:
|
||||
- d7_shortcut_set
|
||||
- d7_user
|
|
@ -20,16 +20,16 @@ function shortcut_help($route_name, RouteMatchInterface $route_match) {
|
|||
switch ($route_name) {
|
||||
case 'help.page.shortcut':
|
||||
$output = '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href="!shortcut">online documentation for the Shortcut module</a>.', array('!shortcut' => 'https://www.drupal.org/documentation/modules/shortcut')) . '</p>';
|
||||
$output .= '<p>' . t('The Shortcut module allows users to create sets of <em>shortcut</em> links to commonly-visited pages of the site. Shortcuts are contained within <em>sets</em>. Each user with <em>Select any shortcut set</em> permission can select a shortcut set created by anyone at the site. For more information, see the <a href=":shortcut">online documentation for the Shortcut module</a>.', array(':shortcut' => 'https://www.drupal.org/documentation/modules/shortcut')) . '</p>';
|
||||
$output .= '<h3>' . t('Uses') . '</h3>';
|
||||
$output .= '<dl><dt>' . t('Administering shortcuts') . '</dt>';
|
||||
$output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href="!shortcuts">Shortcuts administration page</a>.', array('!shortcuts' => \Drupal::url('entity.shortcut_set.collection'))) . '</dd>';
|
||||
$output .= '<dd>' . t('Users with the <em>Administer shortcuts</em> permission can manage shortcut sets and edit the shortcuts within sets from the <a href=":shortcuts">Shortcuts administration page</a>.', array(':shortcuts' => \Drupal::url('entity.shortcut_set.collection'))) . '</dd>';
|
||||
$output .= '<dt>' . t('Choosing shortcut sets') . '</dt>';
|
||||
$output .= '<dd>' . t('Users with permission to switch shortcut sets can choose a shortcut set to use from the Shortcuts tab of their user account page.') . '</dd>';
|
||||
$output .= '<dt>' . t('Adding and removing shortcuts') . '</dt>';
|
||||
$output .= '<dd>' . t('The Shortcut module creates an add/remove link for each page on your site; the link lets you add or remove the current page from the currently-enabled set of shortcuts (if your theme displays it and you have permission to edit your shortcut set). The core Seven administration theme displays this link next to the page title, as a grey or yellow star. If you click on the grey star, you will add that page to your preferred set of shortcuts. If the page is already part of your shortcut set, the link will be a yellow star, and will allow you to remove the current page from your shortcut set.') . '</dd>';
|
||||
$output .= '<dt>' . t('Displaying shortcuts') . '</dt>';
|
||||
$output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href="!blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href="!toolbar-help">Toolbar module</a> provides a corresponding menu item.', array('!blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', '!toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', array('name' => 'toolbar')) : '#')) . '</dd>';
|
||||
$output .= '<dd>' . t('You can display your shortcuts by enabling the <em>Shortcuts</em> block on the <a href=":blocks">Blocks administration page</a>. Certain administrative modules also display your shortcuts; for example, the core <a href=":toolbar-help">Toolbar module</a> provides a corresponding menu item.', array(':blocks' => (\Drupal::moduleHandler()->moduleExists('block')) ? \Drupal::url('block.admin_display') : '#', ':toolbar-help' => (\Drupal::moduleHandler()->moduleExists('toolbar')) ? \Drupal::url('help.page', array('name' => 'toolbar')) : '#')) . '</dd>';
|
||||
$output .= '</dl>';
|
||||
return $output;
|
||||
|
||||
|
@ -38,7 +38,7 @@ function shortcut_help($route_name, RouteMatchInterface $route_match) {
|
|||
case 'entity.shortcut_set.edit_form':
|
||||
$user = \Drupal::currentUser();
|
||||
if ($user->hasPermission('access shortcuts') && $user->hasPermission('switch shortcut sets')) {
|
||||
$output = '<p>' . t('Define which shortcut set you are using on the <a href="@shortcut-link">Shortcuts tab</a> of your account page.', array('@shortcut-link' => \Drupal::url('shortcut.set_switch', array('user' => $user->id())))) . '</p>';
|
||||
$output = '<p>' . t('Define which shortcut set you are using on the <a href=":shortcut-link">Shortcuts tab</a> of your account page.', array(':shortcut-link' => \Drupal::url('shortcut.set_switch', array('user' => $user->id())))) . '</p>';
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
@ -298,9 +298,9 @@ function shortcut_preprocess_block(&$variables) {
|
|||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_HOOK() for page templates.
|
||||
* Implements hook_preprocess_HOOK() for page title templates.
|
||||
*/
|
||||
function shortcut_preprocess_page(&$variables) {
|
||||
function shortcut_preprocess_page_title(&$variables) {
|
||||
// Only display the shortcut link if the user has the ability to edit
|
||||
// shortcuts and if the page's actual content is being shown (for example,
|
||||
// we do not want to display it on "access denied" or "page not found"
|
||||
|
@ -309,9 +309,12 @@ function shortcut_preprocess_page(&$variables) {
|
|||
$link = Url::fromRouteMatch(\Drupal::routeMatch())->getInternalPath();
|
||||
$route_match = \Drupal::routeMatch();
|
||||
|
||||
// Replicate template_preprocess_html()'s processing to get the title in
|
||||
// string form, so we can set the default name for the shortcut.
|
||||
$name = render($variables['title']);
|
||||
$query = array(
|
||||
'link' => $link,
|
||||
'name' => $variables['title'],
|
||||
'name' => $name,
|
||||
);
|
||||
|
||||
$shortcut_set = shortcut_current_displayed_set();
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\shortcut\Entity;
|
||||
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBase;
|
||||
use Drupal\Core\Config\Entity\ConfigEntityBundleBase;
|
||||
use Drupal\Core\Entity\EntityStorageInterface;
|
||||
use Drupal\shortcut\ShortcutSetInterface;
|
||||
|
||||
|
@ -47,7 +47,7 @@ use Drupal\shortcut\ShortcutSetInterface;
|
|||
* }
|
||||
* )
|
||||
*/
|
||||
class ShortcutSet extends ConfigEntityBase implements ShortcutSetInterface {
|
||||
class ShortcutSet extends ConfigEntityBundleBase implements ShortcutSetInterface {
|
||||
|
||||
/**
|
||||
* The machine name for the configuration entity.
|
||||
|
|
|
@ -38,7 +38,7 @@ class SetCustomize extends EntityForm {
|
|||
$form['shortcuts']['links'] = array(
|
||||
'#type' => 'table',
|
||||
'#header' => array(t('Name'), t('Weight'), t('Operations')),
|
||||
'#empty' => $this->t('No shortcuts available. <a href="@link">Add a shortcut</a>', array('@link' => $this->url('shortcut.link_add', array('shortcut_set' => $this->entity->id())))),
|
||||
'#empty' => $this->t('No shortcuts available. <a href=":link">Add a shortcut</a>', array(':link' => $this->url('shortcut.link_add', array('shortcut_set' => $this->entity->id())))),
|
||||
'#attributes' => array('id' => 'shortcuts'),
|
||||
'#tabledrag' => array(
|
||||
array(
|
||||
|
|
|
@ -187,12 +187,12 @@ class SwitchShortcutSet extends FormBase {
|
|||
$replacements = array(
|
||||
'%user' => $this->user->label(),
|
||||
'%set_name' => $set->label(),
|
||||
'@switch-url' => $this->url('<current>'),
|
||||
':switch-url' => $this->url('<current>'),
|
||||
);
|
||||
if ($account_is_user) {
|
||||
// Only administrators can create new shortcut sets, so we know they have
|
||||
// access to switch back.
|
||||
drupal_set_message($this->t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href="@switch-url">switch back to a different one.</a>', $replacements));
|
||||
drupal_set_message($this->t('You are now using the new %set_name shortcut set. You can edit it from this page or <a href=":switch-url">switch back to a different one.</a>', $replacements));
|
||||
}
|
||||
else {
|
||||
drupal_set_message($this->t('%user is now using a new shortcut set called %set_name. You can edit it from this page.', $replacements));
|
||||
|
@ -207,7 +207,7 @@ class SwitchShortcutSet extends FormBase {
|
|||
/* @var \Drupal\shortcut\Entity\ShortcutSet $set */
|
||||
$set = $this->shortcutSetStorage->load($form_state->getValue('set'));
|
||||
$replacements = array(
|
||||
'%user' => $this->user->label(),
|
||||
'%user' => $this->user->getDisplayName(),
|
||||
'%set_name' => $set->label(),
|
||||
);
|
||||
drupal_set_message($account_is_user ? $this->t('You are now using the %set_name shortcut set.', $replacements) : $this->t('%user is now using the %set_name shortcut set.', $replacements));
|
||||
|
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Plugin\migrate\destination\EntityShortcutSet.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Plugin\migrate\destination;
|
||||
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\migrate\Plugin\migrate\destination\EntityConfigBase;
|
||||
|
||||
/**
|
||||
* @MigrateDestination(
|
||||
* id = "entity:shortcut_set"
|
||||
* )
|
||||
*/
|
||||
class EntityShortcutSet extends EntityConfigBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getEntity(Row $row, array $old_destination_id_values) {
|
||||
$entity = parent::getEntity($row, $old_destination_id_values);
|
||||
// Set the "syncing" flag to TRUE, to avoid duplication of default
|
||||
// shortcut links
|
||||
$entity->setSyncing(TRUE);
|
||||
return $entity;
|
||||
}
|
||||
}
|
|
@ -0,0 +1,101 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Plugin\migrate\destination\ShortcutSetUsers.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Plugin\migrate\destination;
|
||||
|
||||
use Drupal\shortcut\ShortcutSetStorageInterface;
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\migrate\Entity\MigrationInterface;
|
||||
use Drupal\migrate\Row;
|
||||
use Drupal\migrate\Plugin\migrate\destination\DestinationBase;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
|
||||
|
||||
/**
|
||||
* @MigrateDestination(
|
||||
* id = "shortcut_set_users"
|
||||
* )
|
||||
*/
|
||||
class ShortcutSetUsers extends DestinationBase implements ContainerFactoryPluginInterface {
|
||||
|
||||
/**
|
||||
* The shortcut set storage handler.
|
||||
*
|
||||
* @var \Drupal\shortcut\ShortcutSetStorageInterface
|
||||
*/
|
||||
protected $shortcutSetStorage;
|
||||
|
||||
/**
|
||||
* Constructs an entity destination plugin.
|
||||
*
|
||||
* @param array $configuration
|
||||
* A configuration array containing information about the plugin instance.
|
||||
* @param string $plugin_id
|
||||
* The plugin_id for the plugin instance.
|
||||
* @param mixed $plugin_definition
|
||||
* The plugin implementation definition.
|
||||
* @param MigrationInterface $migration
|
||||
* The migration.
|
||||
* @param \Drupal\shortcut\ShortcutSetStorageInterface $shortcut_set_storage
|
||||
* The shortcut_set entity storage handler.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration, ShortcutSetStorageInterface $shortcut_set_storage) {
|
||||
parent::__construct($configuration, $plugin_id, $plugin_definition, $migration);
|
||||
$this->shortcutSetStorage = $shortcut_set_storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition, MigrationInterface $migration = NULL) {
|
||||
return new static(
|
||||
$configuration,
|
||||
$plugin_id,
|
||||
$plugin_definition,
|
||||
$migration,
|
||||
$container->get('entity.manager')->getStorage('shortcut_set')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'set_name' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields(MigrationInterface $migration = NULL) {
|
||||
return [
|
||||
'uid' => 'The users.uid for this set.',
|
||||
'source' => 'The shortcut_set.set_name that will be displayed for this user.',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function import(Row $row, array $old_destination_id_values = array()) {
|
||||
/** @var \Drupal\shortcut\ShortcutSetInterface $set */
|
||||
$set = $this->shortcutSetStorage->load($row->getDestinationProperty('set_name'));
|
||||
/** @var \Drupal\user\UserInterface $account */
|
||||
$account = User::load($row->getDestinationProperty('uid'));
|
||||
$this->shortcutSetStorage->assignUser($set, $account);
|
||||
|
||||
return array($set->id(), $account->id());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Plugin\migrate\source\d7\Shortcut.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 shortcut links source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_shortcut",
|
||||
* source_provider = "shortcut"
|
||||
* )
|
||||
*/
|
||||
class Shortcut extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('menu_links', 'ml')
|
||||
->fields('ml', array('mlid', 'menu_name', 'link_path', 'link_title', 'weight'))
|
||||
->condition('hidden', '0')
|
||||
->condition('menu_name', 'shortcut-set-%', 'LIKE');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'mlid' => $this->t("The menu.mlid primary key for this menu item (= shortcut link)."),
|
||||
'menu_name' => $this->t("The menu_name (= set name) for this shortcut link."),
|
||||
'link_path' => $this->t("The link for this shortcut."),
|
||||
'link_title' => $this->t("The title for this shortcut."),
|
||||
'weight' => $this->t("The weight for this shortcut"),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['mlid']['type'] = 'integer';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Plugin\migrate\source\d7\ShortcutSet.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 shortcut_set source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_shortcut_set",
|
||||
* source_provider = "shortcut"
|
||||
* )
|
||||
*/
|
||||
class ShortcutSet extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('shortcut_set', 'ss')->fields('ss');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'set_name' => $this->t("The name under which the set's links are stored."),
|
||||
'title' => $this->t("The title of the set."),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
$ids['set_name']['type'] = 'string';
|
||||
return $ids;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Plugin\migrate\source\d7\ShortcutSetUsers.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
|
||||
|
||||
/**
|
||||
* Drupal 7 shortcut_set_users source from database.
|
||||
*
|
||||
* @MigrateSource(
|
||||
* id = "d7_shortcut_set_users",
|
||||
* source_provider = "shortcut"
|
||||
* )
|
||||
*/
|
||||
class ShortcutSetUsers extends DrupalSqlBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function query() {
|
||||
return $this->select('shortcut_set_users', 'ssu')->fields('ssu');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function fields() {
|
||||
return array(
|
||||
'uid' => $this->t('The users.uid for this set.'),
|
||||
'set_name' => $this->t('The shortcut_set.set_name that will be displayed for this user.'),
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getIds() {
|
||||
return array(
|
||||
'set_name' => array(
|
||||
'type' => 'string',
|
||||
),
|
||||
'uid' => array(
|
||||
'type' => 'integer',
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
}
|
|
@ -55,7 +55,7 @@ class ShortcutAccessControlHandler extends EntityAccessControlHandler implements
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
if ($shortcut_set = $this->shortcutSetStorage->load($entity->bundle())) {
|
||||
return shortcut_set_edit_access($shortcut_set, $account);
|
||||
}
|
||||
|
|
|
@ -22,7 +22,7 @@ class ShortcutSetAccessControlHandler extends EntityAccessControlHandler {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
switch ($operation) {
|
||||
case 'update':
|
||||
if ($account->hasPermission('administer shortcuts')) {
|
||||
|
|
|
@ -7,13 +7,13 @@
|
|||
|
||||
namespace Drupal\shortcut;
|
||||
|
||||
use Drupal\Core\Entity\EntityForm;
|
||||
use Drupal\Core\Entity\BundleEntityFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
||||
/**
|
||||
* Form controller for the shortcut set entity edit forms.
|
||||
*/
|
||||
class ShortcutSetForm extends EntityForm {
|
||||
class ShortcutSetForm extends BundleEntityFormBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
@ -38,14 +38,13 @@ class ShortcutSetForm extends EntityForm {
|
|||
'replace' => '-',
|
||||
),
|
||||
'#default_value' => $entity->id(),
|
||||
'#disabled' => !$entity->isNew(),
|
||||
// This id could be used for menu name.
|
||||
'#maxlength' => 23,
|
||||
);
|
||||
|
||||
$form['actions']['submit']['#value'] = t('Create new set');
|
||||
|
||||
return $form;
|
||||
return $this->protectBundleIdElement($form);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -0,0 +1,77 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Tests\Migrate\d7\MigrateShortcutSetTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\shortcut\Entity\ShortcutSet;
|
||||
use Drupal\shortcut\ShortcutSetInterface;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test shortcut_set migration to ShortcutSet entities.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class MigrateShortcutSetTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $modules = array(
|
||||
'link',
|
||||
'field',
|
||||
'shortcut',
|
||||
'menu_link_content',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('router'));
|
||||
$this->installEntitySchema('shortcut');
|
||||
$this->installEntitySchema('menu_link_content');
|
||||
$this->executeMigration('d7_shortcut_set');
|
||||
$this->executeMigration('menu');
|
||||
$this->executeMigration('d7_menu_links');
|
||||
$this->executeMigration('d7_shortcut');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the shortcut set migration.
|
||||
*/
|
||||
public function testShortcutSetMigration() {
|
||||
$this->assertEntity('default', 'Default', 2);
|
||||
$this->assertEntity('shortcut_set_2', 'Alternative shortcut set', 2);
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of a shortcut set entity.
|
||||
*
|
||||
* @param string $id
|
||||
* The expected shortcut set ID.
|
||||
* @param string $label
|
||||
* The expected shortcut set label.
|
||||
* @param int $expected_size
|
||||
* The number of shortcuts expected to be in the set.
|
||||
*/
|
||||
protected function assertEntity($id, $label, $expected_size) {
|
||||
$shortcut_set = ShortcutSet::load($id);
|
||||
$this->assertTrue($shortcut_set instanceof ShortcutSetInterface);
|
||||
/** @var \Drupal\shortcut\ShortcutSetInterface $shortcut_set */
|
||||
$this->assertIdentical($id, $shortcut_set->id());
|
||||
$this->assertIdentical($label, $shortcut_set->label());
|
||||
|
||||
// Check the number of shortcuts in the set.
|
||||
$shortcuts = $shortcut_set->getShortcuts();
|
||||
$this->assertIdentical(count($shortcuts), $expected_size);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Tests\Migrate\d7\MigrateShortcutSetUsersTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\user\Entity\User;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test shortcut_set_users migration.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class MigrateShortcutSetUsersTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $modules = array(
|
||||
'link',
|
||||
'field',
|
||||
'shortcut',
|
||||
'menu_link_content',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('router'));
|
||||
$this->installEntitySchema('shortcut');
|
||||
$this->installEntitySchema('menu_link_content');
|
||||
$this->installSchema('shortcut', ['shortcut_set_users']);
|
||||
$this->executeMigration('d7_user_role');
|
||||
$this->executeMigration('d7_user');
|
||||
$this->executeMigration('d7_shortcut_set');
|
||||
$this->executeMigration('menu');
|
||||
$this->executeMigration('d7_menu_links');
|
||||
$this->executeMigration('d7_shortcut');
|
||||
$this->executeMigration('d7_shortcut_set_users');
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the shortcut set migration.
|
||||
*/
|
||||
public function testShortcutSetUsersMigration() {
|
||||
// Check if migrated user has correct migrated shortcut set assigned.
|
||||
$account = User::load(2);
|
||||
$shortcut_set = shortcut_current_displayed_set($account);
|
||||
/** @var \Drupal\shortcut\ShortcutSetInterface $shortcut_set */
|
||||
$this->assertIdentical('shortcut_set_2', $shortcut_set->id());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,79 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\shortcut\Tests\Migrate\d7\MigrateShortcutTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\shortcut\Tests\Migrate\d7;
|
||||
|
||||
use Drupal\shortcut\Entity\Shortcut;
|
||||
use Drupal\shortcut\ShortcutInterface;
|
||||
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test shortcut menu links migration to Shortcut entities.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class MigrateShortcutTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
static $modules = array(
|
||||
'link',
|
||||
'field',
|
||||
'shortcut',
|
||||
'menu_link_content',
|
||||
);
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('router'));
|
||||
$this->installEntitySchema('shortcut');
|
||||
$this->installEntitySchema('menu_link_content');
|
||||
$this->executeMigration('d7_shortcut_set');
|
||||
$this->executeMigration('menu');
|
||||
$this->executeMigration('d7_menu_links');
|
||||
$this->executeMigration('d7_shortcut');
|
||||
}
|
||||
|
||||
/**
|
||||
* Asserts various aspects of a shortcut entity.
|
||||
*
|
||||
* @param int $id
|
||||
* The shortcut ID.
|
||||
* @param string $title
|
||||
* The expected title of the shortcut.
|
||||
* @param int $weight
|
||||
* The expected weight of the shortcut.
|
||||
* @param string $url
|
||||
* The expected URL of the shortcut.
|
||||
*/
|
||||
protected function assertEntity($id, $title, $weight, $url) {
|
||||
$shortcut = Shortcut::load($id);
|
||||
$this->assertTrue($shortcut instanceof ShortcutInterface);
|
||||
/** @var \Drupal\shortcut\ShortcutInterface $shortcut */
|
||||
$this->assertIdentical($title, $shortcut->getTitle());
|
||||
$this->assertIdentical($weight, $shortcut->getWeight());
|
||||
$this->assertIdentical($url, $shortcut->getUrl()->toString());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test the shortcut migration.
|
||||
*/
|
||||
public function testShortcutMigration() {
|
||||
// Check if the 4 shortcuts were migrated correctly.
|
||||
$this->assertEntity(1, 'Add content', '-20', '/node/add');
|
||||
$this->assertEntity(2, 'Find content', '-19', '/admin/content');
|
||||
$this->assertEntity(3, 'Help', '-49', '/admin/help');
|
||||
$this->assertEntity(4, 'People', '-50', '/admin/people');
|
||||
}
|
||||
|
||||
}
|
|
@ -26,6 +26,15 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
*/
|
||||
public static $modules = array('router_test', 'views', 'block');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that creating a shortcut works properly.
|
||||
*/
|
||||
|
@ -105,6 +114,21 @@ class ShortcutLinksTest extends ShortcutTestBase {
|
|||
];
|
||||
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $set->id() . '/add-link', $form_data, t('Save'));
|
||||
$this->assertLink($title, 0, 'Shortcut link found on the page.');
|
||||
|
||||
// Create a new shortcut set and add a link to it.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$edit = array(
|
||||
'label' => $this->randomMachineName(),
|
||||
'id' => strtolower($this->randomMachineName()),
|
||||
);
|
||||
$this->drupalPostForm('admin/config/user-interface/shortcut/add-set', $edit, t('Save'));
|
||||
$title = $this->randomMachineName();
|
||||
$form_data = [
|
||||
'title[0][value]' => $title,
|
||||
'link[0][uri]' => '/admin',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/user-interface/shortcut/manage/' . $edit['id'] . '/add-link', $form_data, t('Save'));
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -73,7 +73,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
|
|||
// Test the contents of each th cell.
|
||||
$expected_items = array(t('Name'), t('Weight'), t('Operations'));
|
||||
foreach ($elements as $key => $element) {
|
||||
$this->assertIdentical((string) $element[0], $expected_items[$key]);
|
||||
$this->assertEqual((string) $element[0], $expected_items[$key]);
|
||||
}
|
||||
|
||||
// Look for test shortcuts in the table.
|
||||
|
@ -148,8 +148,7 @@ class ShortcutSetsTest extends ShortcutTestBase {
|
|||
function testShortcutSetSwitchNoSetName() {
|
||||
$edit = array('set' => 'new');
|
||||
$this->drupalPostForm('user/' . $this->adminUser->id() . '/shortcuts', $edit, t('Change set'));
|
||||
$this->assertRaw('1 error has been found:');
|
||||
$this->assertRaw('<a href="#edit-label">Label</a>');
|
||||
$this->assertText(t('The new set label is required.'));
|
||||
$current_set = shortcut_current_displayed_set($this->adminUser);
|
||||
$this->assertEqual($current_set->id(), $this->set->id(), 'Attempting to switch to a new shortcut set without providing a set name does not succeed.');
|
||||
$this->assertFieldByXPath("//input[@name='label' and contains(concat(' ', normalize-space(@class), ' '), ' error ')]", NULL, 'The new set label field has the error class');
|
||||
|
|
|
@ -21,7 +21,7 @@ class ShortcutTranslationUITest extends ContentTranslationUITestBase {
|
|||
/**
|
||||
* {inheritdoc}
|
||||
*/
|
||||
protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'user', 'url.path', 'url.query_args', 'url.site'];
|
||||
protected $defaultCacheContexts = ['languages:language_interface', 'session', 'theme', 'user', 'url.path', 'url.query_args', 'url.site'];
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7\ShortcutSetTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 ShortcutSet source plugin.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class ShortcutSetTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\shortcut\Plugin\migrate\source\d7\ShortcutSet';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_shortcut_set',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'set_name' => 'shortcut-set-2',
|
||||
'title' => 'Alternative shortcut set',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['shortcut_set'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,43 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7\ShortcutSetUsersTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 ShortcutSetUsers source plugin.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class ShortcutSetUsersTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\shortcut\Plugin\migrate\source\d7\ShortcutSetUsers';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_shortcut_set_users',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'uid' => '2',
|
||||
'set_name' => 'shortcut-set-2',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['shortcut_set_users'] = $this->expectedResults;
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7\ShortcutTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\shortcut\Unit\Plugin\migrate\source\d7;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
||||
/**
|
||||
* Tests D7 Shortcut source plugin.
|
||||
*
|
||||
* @group shortcut
|
||||
*/
|
||||
class ShortcutTest extends MigrateSqlSourceTestCase {
|
||||
|
||||
const PLUGIN_CLASS = 'Drupal\shortcut\Plugin\migrate\source\d7\Shortcut';
|
||||
|
||||
protected $migrationConfiguration = [
|
||||
'id' => 'test',
|
||||
'source' => [
|
||||
'plugin' => 'd7_shortcut',
|
||||
],
|
||||
];
|
||||
|
||||
protected $expectedResults = [
|
||||
[
|
||||
'mlid' => '473',
|
||||
'menu_name' => 'shortcut-set-2',
|
||||
'link_path' => 'admin/people',
|
||||
'link_title' => 'People',
|
||||
'weight' => '-50',
|
||||
],
|
||||
];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->databaseContents['menu_links'][] = [
|
||||
'menu_name' => 'shortcut-set-2',
|
||||
'mlid' => '473',
|
||||
'plid' => '0',
|
||||
'link_path' => 'admin/people',
|
||||
'router_path' => 'admin/people',
|
||||
'link_title' => 'People',
|
||||
'options' => 'a:0:{}',
|
||||
'module' => 'menu',
|
||||
'hidden' => '0',
|
||||
'external' => '0',
|
||||
'has_children' => '0',
|
||||
'expanded' => '0',
|
||||
'weight' => '-50',
|
||||
'depth' => '1',
|
||||
'customized' => '0',
|
||||
'p1' => '473',
|
||||
'p2' => '0',
|
||||
'p3' => '0',
|
||||
'p4' => '0',
|
||||
'p5' => '0',
|
||||
'p6' => '0',
|
||||
'p7' => '0',
|
||||
'p8' => '0',
|
||||
'p9' => '0',
|
||||
'updated' => '0',
|
||||
];
|
||||
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
}
|
Reference in a new issue