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

@ -18,10 +18,10 @@ function menu_link_content_help($route_name, RouteMatchInterface $route_match) {
$output .= '<h3>' . t('About') . '</h3>';
$output .= '<p>' . t('The Custom Menu Links module allows users to create menu links. These links can be translated if multiple languages are used for the site.');
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
$output .= ' ' . t('It is required by the Menu UI module, which provides an interface for managing menus and menu links. For more information, see the <a href="!menu-help">Menu UI module help page</a> and the <a href="!drupal-org-help">online documentation for the Custom Menu Links module</a>.', array('!menu-help' => \Drupal::url('help.page', array('name' => 'menu_ui')), '!drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
$output .= ' ' . t('It is required by the Menu UI module, which provides an interface for managing menus and menu links. For more information, see the <a href=":menu-help">Menu UI module help page</a> and the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>.', array(':menu-help' => \Drupal::url('help.page', array('name' => 'menu_ui')), ':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
}
else {
$output .= ' ' . t('For more information, see the <a href="!drupal-org-help">online documentation for the Custom Menu Links module</a>. If you enable the Menu UI module, it provides an interface for managing menus and menu links.', array('!drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
$output .= ' ' . t('For more information, see the <a href=":drupal-org-help">online documentation for the Custom Menu Links module</a>. If you enable the Menu UI module, it provides an interface for managing menus and menu links.', array(':drupal-org-help' => 'https://www.drupal.org/documentation/modules/menu_link'));
}
$output .= '</p>';
return $output;

View file

@ -1,5 +1,5 @@
id: d6_menu_links
label: Drupal 6 menu links
label: Menu links
migration_tags:
- Drupal 6
source:

View file

@ -1,5 +1,5 @@
id: d7_menu_links
label: Drupal 7 menu links
label: Menu links
migration_tags:
- Drupal 7
source:
@ -33,10 +33,10 @@ process:
source:
- link_path
- options
route_name: @route/route_name
route_parameters: @route/route_parameters
url: @route/url
options: @route/options
route_name: '@route/route_name'
route_parameters: '@route/route_parameters'
url: '@route/url'
options: '@route/options'
external: external
weight: weight
expanded: expanded

View file

@ -132,13 +132,6 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
return (int) $this->get('weight')->value;
}
/**
* {@inheritdoc}
*/
public function getChangedTime() {
return $this->get('changed')->value;
}
/**
* {@inheritdoc}
*/
@ -261,9 +254,7 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setDescription(t('The text to be used for this link in the menu.'))
->setRequired(TRUE)
->setTranslatable(TRUE)
->setSettings(array(
'max_length' => 255,
))
->setSetting('max_length', 255)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'string',
@ -279,9 +270,7 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
->setLabel(t('Description'))
->setDescription(t('Shown when hovering over the menu link.'))
->setTranslatable(TRUE)
->setSettings(array(
'max_length' => 255,
))
->setSetting('max_length', 255)
->setDisplayOptions('view', array(
'label' => 'hidden',
'type' => 'string',

View file

@ -51,7 +51,7 @@ class MenuLinkContentAccessControlHandler extends EntityAccessControlHandler imp
/**
* {@inheritdoc}
*/
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
switch ($operation) {
case 'view':
// There is no direct viewing of a menu link, but still for purposes of

View file

@ -25,6 +25,8 @@ class MenuLink extends DrupalSqlBase {
public function query() {
return $this->select('menu_links', 'ml')
->fields('ml')
->orderby('ml.depth')
->orderby('ml.mlid')
->condition('module', 'menu')
->condition('customized', 1);
}

View file

@ -9,7 +9,7 @@ namespace Drupal\menu_link_content\Tests;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\StringTranslation\TranslationWrapper;
use Drupal\Core\StringTranslation\TranslatableMarkup;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\simpletest\KernelTestBase;
use Symfony\Component\Routing\Route;
@ -46,11 +46,12 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
\Drupal::service('router.builder')->rebuild();
// Set up a custom menu link pointing to a specific path.
MenuLinkContent::create([
$parent = MenuLinkContent::create([
'title' => '<script>alert("Welcome to the discovered jungle!")</script>',
'link' => [['uri' => 'internal:/example-path']],
'menu_name' => 'tools',
])->save();
]);
$parent->save();
$menu_tree = \Drupal::menuTree()->load('tools', new MenuTreeParameters());
$this->assertEqual(1, count($menu_tree));
/** @var \Drupal\Core\Menu\MenuLinkTreeElement $tree_element */
@ -70,9 +71,42 @@ class MenuLinkContentDeriverTest extends KernelTestBase {
$tree_element = reset($menu_tree);
$this->assertEqual('route_name_2', $tree_element->link->getRouteName());
$title = $tree_element->link->getTitle();
$this->assertFalse($title instanceof TranslationWrapper);
$this->assertFalse($title instanceof TranslatableMarkup);
$this->assertIdentical('<script>alert("Welcome to the discovered jungle!")</script>', $title);
$this->assertFalse(SafeMarkup::isSafe($title));
// Create a hierarchy.
\Drupal::state()->set('menu_link_content_dynamic_route.routes', [
'route_name_1' => new Route('/example-path'),
'route_name_2' => new Route('/example-path/child'),
]);
$child = MenuLinkContent::create([
'title' => 'Child',
'link' => [['uri' => 'entity:/example-path/child']],
'menu_name' => 'tools',
'parent' => 'menu_link_content:' . $parent->uuid(),
]);
$child->save();
$parent->set('link', [['uri' => 'entity:/example-path']]);
$parent->save();
$menu_tree = \Drupal::menuTree()->load('tools', new MenuTreeParameters());
$this->assertEqual(1, count($menu_tree));
/** @var \Drupal\Core\Menu\MenuLinkTreeElement $tree_element */
$tree_element = reset($menu_tree);
$this->assertTrue($tree_element->hasChildren);
$this->assertEqual(1, count($tree_element->subtree));
// Edit child element link to use 'internal' instead of 'entity'.
$child->set('link', [['uri' => 'internal:/example-path/child']]);
$child->save();
\Drupal::service('plugin.manager.menu.link')->rebuild();
$menu_tree = \Drupal::menuTree()->load('tools', new MenuTreeParameters());
$this->assertEqual(1, count($menu_tree));
/** @var \Drupal\Core\Menu\MenuLinkTreeElement $tree_element */
$tree_element = reset($menu_tree);
$this->assertTrue($tree_element->hasChildren);
$this->assertEqual(1, count($tree_element->subtree));
}
}

View file

@ -20,7 +20,7 @@ class MenuLinkContentTranslationUITest extends ContentTranslationUITestBase {
/**
* {inheritdoc}
*/
protected $defaultCacheContexts = ['languages:language_interface', 'theme', 'url.path', 'url.query_args', 'user.permissions', 'user.roles:authenticated'];
protected $defaultCacheContexts = ['languages:language_interface', 'session', 'theme', 'url.path', 'url.query_args', 'user.permissions', 'user.roles:authenticated'];
/**
* Modules to enable.

View file

@ -18,11 +18,9 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('link', 'menu_ui', 'menu_link_content');
public static $modules = array('menu_ui', 'menu_link_content');
/**
* {@inheritdoc}
@ -31,8 +29,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
parent::setUp();
$this->installSchema('system', ['router']);
$this->installEntitySchema('menu_link_content');
$this->executeMigration('menu');
$this->executeMigration('d6_menu_links');
$this->executeMigrations(['menu', 'd6_menu_links']);
}
/**
@ -47,7 +44,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
$this->assertIdentical(FALSE, $menu_link->isExpanded());
$this->assertIdentical(['attributes' => ['title' => 'Test menu link 1']], $menu_link->link->options);
$this->assertIdentical('internal:/user/login', $menu_link->link->uri);
$this->assertIdentical(15, $menu_link->getWeight());
$this->assertIdentical(-50, $menu_link->getWeight());
$menu_link = MenuLinkContent::load(139);
$this->assertIdentical('Test 2', $menu_link->getTitle());
@ -57,7 +54,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
$this->assertIdentical(TRUE, $menu_link->isExpanded());
$this->assertIdentical(['query' => 'foo=bar', 'attributes' => ['title' => 'Test menu link 2']], $menu_link->link->options);
$this->assertIdentical('internal:/admin', $menu_link->link->uri);
$this->assertIdentical(12, $menu_link->getWeight());
$this->assertIdentical(-49, $menu_link->getWeight());
$menu_link = MenuLinkContent::load(140);
$this->assertIdentical('Drupal.org', $menu_link->getTitle());
@ -67,7 +64,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
$this->assertIdentical(FALSE, $menu_link->isExpanded());
$this->assertIdentical(['attributes' => ['title' => '']], $menu_link->link->options);
$this->assertIdentical('https://www.drupal.org', $menu_link->link->uri);
$this->assertIdentical(0, $menu_link->getWeight());
$this->assertIdentical(-50, $menu_link->getWeight());
// assert that missing title attributes don't stop or break migration.
$menu_link = MenuLinkContent::load(393);
@ -78,7 +75,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
$this->assertIdentical(FALSE, $menu_link->isExpanded());
$this->assertIdentical([], $menu_link->link->options);
$this->assertIdentical('internal:/user/login', $menu_link->link->uri);
$this->assertIdentical(15, $menu_link->getWeight());
$this->assertIdentical(-47, $menu_link->getWeight());
}
}

View file

@ -20,9 +20,7 @@ use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
/**
* Modules to enable.
*
* @var array
* {@inheritdoc}
*/
public static $modules = array('link', 'menu_ui', 'menu_link_content');