Loading core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php +32 −0 Changes for core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,35 @@ /** * Drupal menu link source from database. * * Available configuration keys: * - menu_name: (optional) The menu name(s) to filter menu links from the source * can be a string or an array. If not declared then menu links of all menus * are retrieved. * * Examples: * * @code * source: * plugin: menu_link * menu_name: main-menu * @endcode * * In this example menu links of main-menu are retrieved from the source * database. * * @code * source: * plugin: menu_link * menu_name: [main-menu, navigation] * @endcode * * In this example menu links of main-menu and navigation menus are retrieved * from the source database. * * For additional configuration keys, refer to the parent classes: * @see \Drupal\migrate\Plugin\migrate\source\SqlBase * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase * * @MigrateSource( * id = "menu_link", * source_module = "menu" Loading @@ -29,6 +58,9 @@ public function query() { ->condition('ml.customized', 1) ->condition($and); $query->condition($condition); if (isset($this->configuration['menu_name'])) { $query->condition('ml.menu_name', (array) $this->configuration['menu_name'], 'IN'); } $query->leftJoin('menu_links', 'pl', '[ml].[plid] = [pl].[mlid]'); $query->addField('pl', 'link_path', 'parent_link_path'); $query->orderBy('ml.depth'); Loading core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php +21 −1 Changes for core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php: 21 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ public function providerSource() { ], [ // D7 non-customized menu link, provided by menu module. 'menu_name' => 'menu-test-menu', 'menu_name' => 'menu-test2-menu', 'mlid' => 300, 'plid' => 0, 'link_path' => 'node/142', Loading Loading @@ -270,6 +270,26 @@ public function providerSource() { $tests[0]['expected_data'][] = $expected[3]; $tests[0]['expected_data'][] = $expected[4]; // Tests retrieval of links from multiple menus. $tests[1] = $tests[0]; $tests[1]['expected_count'] = NULL; $tests[1]['configuration'] = [ 'menu_name' => ['menu-test-menu', 'menu-test2-menu'], ]; // Tests retrieval of links from a single menu. $tests[2] = $tests[1]; $tests[2]['configuration'] = [ 'menu_name' => 'menu-test2-menu', ]; $tests[2]['expected_data'] = [$expected[6]]; // Tests retrieval of links from a not existing menu. $tests[3] = $tests[1]; $tests[3]['configuration'] = [ 'menu_name' => 'menu-not-exists', ]; $tests[3]['expected_data'] = []; return $tests; } Loading Loading
core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php +32 −0 Changes for core/modules/menu_link_content/src/Plugin/migrate/source/MenuLink.php: 32 added lines, 0 removed lines. Original line number Diff line number Diff line Loading @@ -9,6 +9,35 @@ /** * Drupal menu link source from database. * * Available configuration keys: * - menu_name: (optional) The menu name(s) to filter menu links from the source * can be a string or an array. If not declared then menu links of all menus * are retrieved. * * Examples: * * @code * source: * plugin: menu_link * menu_name: main-menu * @endcode * * In this example menu links of main-menu are retrieved from the source * database. * * @code * source: * plugin: menu_link * menu_name: [main-menu, navigation] * @endcode * * In this example menu links of main-menu and navigation menus are retrieved * from the source database. * * For additional configuration keys, refer to the parent classes: * @see \Drupal\migrate\Plugin\migrate\source\SqlBase * @see \Drupal\migrate\Plugin\migrate\source\SourcePluginBase * * @MigrateSource( * id = "menu_link", * source_module = "menu" Loading @@ -29,6 +58,9 @@ public function query() { ->condition('ml.customized', 1) ->condition($and); $query->condition($condition); if (isset($this->configuration['menu_name'])) { $query->condition('ml.menu_name', (array) $this->configuration['menu_name'], 'IN'); } $query->leftJoin('menu_links', 'pl', '[ml].[plid] = [pl].[mlid]'); $query->addField('pl', 'link_path', 'parent_link_path'); $query->orderBy('ml.depth'); Loading
core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php +21 −1 Changes for core/modules/menu_link_content/tests/src/Kernel/Plugin/migrate/source/MenuLinkTest.php: 21 added lines, 1 removed line. Original line number Diff line number Diff line Loading @@ -212,7 +212,7 @@ public function providerSource() { ], [ // D7 non-customized menu link, provided by menu module. 'menu_name' => 'menu-test-menu', 'menu_name' => 'menu-test2-menu', 'mlid' => 300, 'plid' => 0, 'link_path' => 'node/142', Loading Loading @@ -270,6 +270,26 @@ public function providerSource() { $tests[0]['expected_data'][] = $expected[3]; $tests[0]['expected_data'][] = $expected[4]; // Tests retrieval of links from multiple menus. $tests[1] = $tests[0]; $tests[1]['expected_count'] = NULL; $tests[1]['configuration'] = [ 'menu_name' => ['menu-test-menu', 'menu-test2-menu'], ]; // Tests retrieval of links from a single menu. $tests[2] = $tests[1]; $tests[2]['configuration'] = [ 'menu_name' => 'menu-test2-menu', ]; $tests[2]['expected_data'] = [$expected[6]]; // Tests retrieval of links from a not existing menu. $tests[3] = $tests[1]; $tests[3]['configuration'] = [ 'menu_name' => 'menu-not-exists', ]; $tests[3]['expected_data'] = []; return $tests; } Loading