Update to Drupal 8.0.2. For more information, see https://www.drupal.org/drupal-8.0.2-release-notes

This commit is contained in:
Pantheon Automation 2016-01-06 16:31:26 -08:00 committed by Greg Anderson
parent 1a0e9d9fac
commit a6b049dd05
538 changed files with 5247 additions and 1594 deletions

View file

@ -200,15 +200,22 @@ class MenuLinkContent extends ContentEntityBase implements MenuLinkContentInterf
// The menu link can just be updated if there is already an menu link entry
// on both entity and menu link plugin level.
if ($update && $menu_link_manager->getDefinition($this->getPluginId())) {
$definition = $this->getPluginDefinition();
// Even when $update is FALSE, for top level links it is possible the link
// already is in the storage because of the getPluginDefinition() call
// above, see https://www.drupal.org/node/2605684#comment-10515450 for the
// call chain. Because of this the $update flag is ignored and only the
// existence of the definition (equals to being in the tree storage) is
// checked.
if ($menu_link_manager->getDefinition($this->getPluginId(), FALSE)) {
// When the entity is saved via a plugin instance, we should not call
// the menu tree manager to update the definition a second time.
if (!$this->insidePlugin) {
$menu_link_manager->updateDefinition($this->getPluginId(), $this->getPluginDefinition(), FALSE);
$menu_link_manager->updateDefinition($this->getPluginId(), $definition, FALSE);
}
}
else {
$menu_link_manager->addDefinition($this->getPluginId(), $this->getPluginDefinition());
$menu_link_manager->addDefinition($this->getPluginId(), $definition);
}
}

View file

@ -7,6 +7,7 @@
namespace Drupal\menu_link_content\Plugin\migrate\source;
use Drupal\Component\Utility\Unicode;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
use Drupal\migrate\Row;
@ -23,12 +24,20 @@ class MenuLink extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
return $this->select('menu_links', 'ml')
->fields('ml')
->orderby('ml.depth')
->orderby('ml.mlid')
->condition('module', 'menu')
->condition('customized', 1);
$query = $this->select('menu_links', 'ml')
->fields('ml');
$and = $query->andConditionGroup()
->condition('ml.module', 'menu')
->condition('ml.router_path', ['admin/build/menu-customize/%', 'admin/structure/menu/manage/%'], 'NOT IN');
$condition = $query->orConditionGroup()
->condition('ml.customized', 1)
->condition($and);
$query->condition($condition);
$query->leftJoin('menu_links', 'pl', 'ml.plid = pl.mlid');
$query->addField('pl', 'link_path', 'parent_link_path');
$query->orderBy('ml.depth');
$query->orderby('ml.mlid');
return $query;
}
/**
@ -70,6 +79,7 @@ class MenuLink extends DrupalSqlBase {
public function prepareRow(Row $row) {
$row->setSourceProperty('options', unserialize($row->getSourceProperty('options')));
$row->setSourceProperty('enabled', !$row->getSourceProperty('hidden'));
$row->setSourceProperty('description', Unicode::truncate($row->getSourceProperty('options/attributes/title'), 255));
return parent::prepareRow($row);
}
@ -79,6 +89,7 @@ class MenuLink extends DrupalSqlBase {
*/
public function getIds() {
$ids['mlid']['type'] = 'integer';
$ids['mlid']['alias'] = 'ml';
return $ids;
}

View file

@ -29,7 +29,7 @@ class MigrateMenuLinkTest extends MigrateDrupal6TestBase {
parent::setUp();
$this->installSchema('system', ['router']);
$this->installEntitySchema('menu_link_content');
$this->executeMigrations(['menu', 'd6_menu_links']);
$this->executeMigrations(['menu', 'menu_links']);
}
/**

View file

@ -8,6 +8,8 @@
namespace Drupal\menu_link_content\Tests\Migrate\d7;
use Drupal\Core\Database\Database;
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\Core\Url;
use Drupal\menu_link_content\Entity\MenuLinkContent;
use Drupal\menu_link_content\MenuLinkContentInterface;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
@ -18,6 +20,7 @@ use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
* @group menu_link_content
*/
class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
const MENU_NAME = 'menu-test-menu';
/**
* {@inheritdoc}
@ -32,6 +35,7 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
$this->installSchema('system', ['router']);
$this->installEntitySchema('menu_link_content');
$this->executeMigration('menu');
\Drupal::service('router.builder')->rebuild();
}
/**
@ -70,16 +74,44 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
$this->assertIdentical($attributes, $menu_link->link->options);
$this->assertIdentical($uri, $menu_link->link->uri);
$this->assertIdentical($weight, $menu_link->getWeight());
return $menu_link;
}
/**
* Tests migration of menu links.
*/
public function testMenuLinks() {
$this->executeMigration('d7_menu_links');
$this->assertEntity(467, 'Google', 'menu-test-menu', 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
$this->assertEntity(468, 'Yahoo', 'menu-test-menu', 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
$this->assertEntity(469, 'Bing', 'menu-test-menu', 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
$this->executeMigration('menu_links');
$this->assertEntity(469, 'Bing', static::MENU_NAME, 'Bing', TRUE, FALSE, ['attributes' => ['title' => 'Bing']], 'http://bing.com', 0);
$this->assertEntity(467, 'Google', static::MENU_NAME, 'Google', TRUE, FALSE, ['attributes' => ['title' => 'Google']], 'http://google.com', 0);
$this->assertEntity(468, 'Yahoo', static::MENU_NAME, 'Yahoo', TRUE, FALSE, ['attributes' => ['title' => 'Yahoo']], 'http://yahoo.com', 0);
$menu_link_tree_service = \Drupal::service('menu.link_tree');
$parameters = new MenuTreeParameters();
$tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
$this->assertEqual(2, count($tree));
$children = 0;
$google_found = FALSE;
foreach ($tree as $menu_link_tree_element) {
$children += $menu_link_tree_element->hasChildren;
if ($menu_link_tree_element->link->getUrlObject()->toString() == 'http://bing.com') {
$this->assertEqual(reset($menu_link_tree_element->subtree)->link->getUrlObject()->toString(), 'http://google.com');
$google_found = TRUE;
}
}
$this->assertEqual(1, $children);
$this->assertTrue($google_found);
// Now find the custom link under a system link.
$parameters->root = 'system.admin_structure';
$tree = $menu_link_tree_service->load(static::MENU_NAME, $parameters);
$found = FALSE;
foreach ($tree as $menu_link_tree_element) {
$this->pass($menu_link_tree_element->link->getUrlObject()->toString());
if ($menu_link_tree_element->link->getTitle() == 'custom link test') {
$found = TRUE;
break;
}
}
$this->assertTrue($found);
}
/**
@ -94,8 +126,8 @@ class MigrateMenuLinkTest extends MigrateDrupal7TestBase {
->condition('mlid', 467)
->execute();
$this->executeMigration('d7_menu_links');
$this->assertEntity(467, 'Google', 'menu-test-menu', NULL, TRUE, FALSE, [], 'http://google.com', 0);
$this->executeMigration('menu_links');
$this->assertEntity(467, 'Google', static::MENU_NAME, NULL, TRUE, FALSE, [], 'http://google.com', 0);
}
}