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
|
@ -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',
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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');
|
||||
|
||||
|
|
Reference in a new issue