updated contrib modules
This commit is contained in:
@@ -1,3 +1,24 @@
|
||||
Admin Toolbar 8.1.22, 2017-XX-XX
|
||||
--------------------------------
|
||||
Changes since 8.1.21:
|
||||
|
||||
- #2929061 by romainj, dsnopek, adriancid: admin_toolbar_links_access_filter
|
||||
doesn't do anything unless admin_toolbar is enabled.
|
||||
- #2928836 by eme: One extra pixel line under the admin toolbar.
|
||||
- #2925501 by eme, adriancid, RumyanaRuseva: Menu does not take changes into
|
||||
account (caching issue).
|
||||
- #2927914 by adriancid: Parameter comment indentation must be 3 spaces.
|
||||
- #2927911 by adriancid: Remove unused variables.
|
||||
- #2927905 by adriancid: All dependencies must be prefixed with the project
|
||||
name.
|
||||
- #2925327 by Berdir, adriancid: Better check for is-link-in-admin-menu for
|
||||
local task links.
|
||||
- #2922046 by mikejw, adriancid, Berdir, BrianLewisDesign: Notice: Undefined
|
||||
index: entity.eform_type.collection in
|
||||
admin_toolbar_tools_menu_links_discovered_alter.
|
||||
- #2925128 by adriancid: Create the module help page for the Admin Toolbar Links
|
||||
Access Filter submodule.
|
||||
|
||||
Admin Toolbar 8.1.21, 2017-11-20
|
||||
--------------------------------
|
||||
Changes since 8.1.20:
|
||||
|
||||
@@ -6,10 +6,10 @@ type: module
|
||||
# core: 8.x
|
||||
|
||||
dependencies:
|
||||
- toolbar
|
||||
- drupal:toolbar
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-20
|
||||
version: '8.x-1.21'
|
||||
# Information added by Drupal.org packaging script on 2018-01-02
|
||||
version: '8.x-1.22'
|
||||
core: '8.x'
|
||||
project: 'admin_toolbar'
|
||||
datestamp: 1511190792
|
||||
datestamp: 1514888588
|
||||
|
||||
+3
-1
@@ -27,7 +27,9 @@ https://www.drupal.org/node/296693 be solved, this module will be deprecated.
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
No special requirements.
|
||||
This module requires the following modules:
|
||||
|
||||
* Admin Toolbar (https://www.drupal.org/project/admin_toolbar)
|
||||
|
||||
|
||||
RECOMMENDED MODULES
|
||||
|
||||
+5
-4
@@ -1,12 +1,13 @@
|
||||
name: Admin Toolbar Links Access Filter
|
||||
description: Provides a workaround for the common problem that users with 'Use the administration pages and help' permission see menu links they don't have access permission for. Once the issue <a href='https://www.drupal.org/node/296693'>https://www.drupal.org/node/296693</a> be solved, this module will be deprecated.
|
||||
package: Administration
|
||||
|
||||
dependencies:
|
||||
- admin_toolbar:admin_toolbar
|
||||
type: module
|
||||
# core: 8.x
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-20
|
||||
version: '8.x-1.21'
|
||||
# Information added by Drupal.org packaging script on 2018-01-02
|
||||
version: '8.x-1.22'
|
||||
core: '8.x'
|
||||
project: 'admin_toolbar'
|
||||
datestamp: 1511190792
|
||||
datestamp: 1514888588
|
||||
|
||||
+17
@@ -9,6 +9,22 @@ use Drupal\Core\Session\AccountInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Symfony\Component\Routing\Exception\RouteNotFoundException;
|
||||
use Drupal\Core\Routing\RouteMatchInterface;
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
function admin_toolbar_links_access_filter_help($route_name, RouteMatchInterface $route_match) {
|
||||
switch ($route_name) {
|
||||
// Main module help.
|
||||
case 'help.page.admin_toolbar_links_access_filter':
|
||||
$output = '';
|
||||
$output .= '<h3>' . t('About') . '</h3>';
|
||||
$output .= '<p>' . t("The Admin Toolbar Links Access Filter module Provides a workaround for the common problem that users with <em>Use the administration pages and help</em> permission see menu links they don't have access permission for. Once the issue <a href='@url'>Hide empty admin categories</a> be solved, this module will be deprecated.", ['@url' => Url::fromUri('https://www.drupal.org/node/296693')->toString()]) . '</p>';
|
||||
|
||||
return $output;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_preprocess_menu().
|
||||
@@ -152,6 +168,7 @@ function admin_toolbar_links_access_filter_is_overview_page($route_name) {
|
||||
return !empty($controller) && in_array($controller, $overview_page_controllers);
|
||||
}
|
||||
catch (RouteNotFoundException $ex) {
|
||||
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,10 +6,10 @@ type: module
|
||||
# core: 8.x
|
||||
|
||||
dependencies:
|
||||
- admin_toolbar
|
||||
- admin_toolbar:admin_toolbar
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-11-20
|
||||
version: '8.x-1.21'
|
||||
# Information added by Drupal.org packaging script on 2018-01-02
|
||||
version: '8.x-1.22'
|
||||
core: '8.x'
|
||||
project: 'admin_toolbar'
|
||||
datestamp: 1511190792
|
||||
datestamp: 1514888588
|
||||
|
||||
+44
@@ -12,6 +12,13 @@ system.admin_index:
|
||||
parent: admin_toolbar_tools.help
|
||||
weight: -100
|
||||
|
||||
system.run_cron:
|
||||
title: 'Run cron'
|
||||
route_name: admin_toolbar.run.cron
|
||||
menu_name: admin
|
||||
parent: admin_toolbar_tools.help
|
||||
weight: -8
|
||||
|
||||
system.db_update:
|
||||
title: 'Run updates'
|
||||
route_name: system.db_update
|
||||
@@ -25,6 +32,43 @@ system.modules_uninstall:
|
||||
menu_name: admin
|
||||
parent: system.modules_list
|
||||
|
||||
admin_toolbar_tools.flush:
|
||||
title: 'Flush all caches'
|
||||
route_name: admin_toolbar_tools.flush
|
||||
weight: -9
|
||||
parent: admin_toolbar_tools.help
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.cssjs:
|
||||
title: 'Flush CSS and Javascript'
|
||||
route_name: admin_toolbar_tools.cssjs
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.plugin:
|
||||
title: 'Flush plugins cache'
|
||||
route_name: admin_toolbar_tools.plugin
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_static:
|
||||
title: 'Flush static cache'
|
||||
route_name: admin_toolbar_tools.flush_static
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_menu:
|
||||
title: 'Flush routing and links cache'
|
||||
route_name: admin_toolbar_tools.flush_menu
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.flush_rendercache:
|
||||
title: 'Flush render cache'
|
||||
route_name: admin_toolbar_tools.flush_rendercache
|
||||
parent: admin_toolbar_tools.flush
|
||||
menu_name: admin
|
||||
|
||||
admin_toolbar_tools.drupalorg:
|
||||
title: 'Drupal.org'
|
||||
weight: -5
|
||||
|
||||
+43
-18
@@ -28,17 +28,6 @@ function admin_toolbar_tools_toolbar() {
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_toolbar_alter().
|
||||
*/
|
||||
function admin_toolbar_tools_toolbar_alter(&$items) {
|
||||
// Use lazybuilder for links so the page is cacheable.
|
||||
$items['administration']['tray']['toolbar_administration'] = [
|
||||
'#lazy_builder' => ['admin_toolbar_tools.toolbar_handler:lazyBuilder', []],
|
||||
'#create_placeholder' => TRUE,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_help().
|
||||
*/
|
||||
@@ -88,8 +77,18 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
|
||||
}
|
||||
}
|
||||
|
||||
// Adding a menu link to clean the Views cache.
|
||||
if ($moduleHandler->moduleExists('views')) {
|
||||
$links['admin_toolbar_tools.flush_views'] = [
|
||||
'title' => t('Flush views cache'),
|
||||
'route_name' => 'admin_toolbar_tools.flush_views',
|
||||
'menu_name' => 'admin',
|
||||
'parent' => 'admin_toolbar_tools.flush',
|
||||
];
|
||||
}
|
||||
|
||||
// Adds common links to entities.
|
||||
foreach ($content_entities as $module_name => $entities) {
|
||||
foreach ($content_entities as $entities) {
|
||||
$content_entity_bundle = $entities['content_entity_bundle'];
|
||||
$content_entity = $entities['content_entity'];
|
||||
foreach ($entityTypeManager->getStorage($content_entity_bundle)->loadMultiple() as $machine_name => $bundle) {
|
||||
@@ -539,19 +538,45 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
|
||||
$manager = \Drupal::service('plugin.manager.menu.local_task');
|
||||
foreach ($links as $key => $link) {
|
||||
|
||||
// Ignore menu links that have no route name or are not in the admin menu.
|
||||
// @todo Use configuration for admin menu name once added in
|
||||
// https://www.drupal.org/node/1869638.
|
||||
if (empty($link['route_name']) || !isset($link['menu_name']) || $link['menu_name'] !== 'admin') {
|
||||
// Ignore menu links that have no route name.
|
||||
if (empty($link['route_name'])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
// Ignore links that are not in the admin menu, include parents in the
|
||||
// check as they inherit the menu name from the parent if not set.
|
||||
$link_to_check = $link;
|
||||
do {
|
||||
// @todo Use configuration for admin menu name once added in
|
||||
// https://www.drupal.org/node/1869638.
|
||||
if (isset($link_to_check['menu_name'])) {
|
||||
// If the link belongs to the admin menu, then skip this loop and
|
||||
// look for local tasks.
|
||||
if ($link_to_check['menu_name'] === 'admin') {
|
||||
break;
|
||||
}
|
||||
else {
|
||||
// If it is explicitly not in the admin menu, skip.
|
||||
continue 2;
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($link_to_check['parent']) && isset($links[$link_to_check['parent']])) {
|
||||
$link_to_check = $links[$link_to_check['parent']];
|
||||
}
|
||||
else {
|
||||
// No parent and we found no menu_name, skip.
|
||||
continue 2;
|
||||
}
|
||||
} while ($link_to_check);
|
||||
|
||||
$route = $link['route_name'];
|
||||
$route_local_tasks = $manager->getLocalTasksForRoute($route);
|
||||
if (empty($route_local_tasks[0])) {
|
||||
continue;
|
||||
}
|
||||
|
||||
foreach ($route_local_tasks[0] as $plugin_id => $task_plugin) {
|
||||
foreach ($route_local_tasks[0] as $task_plugin) {
|
||||
$definition = $task_plugin->getPluginDefinition();
|
||||
$local_route = $definition['route_name'];
|
||||
if (empty($local_route)) {
|
||||
@@ -596,7 +621,7 @@ function admin_toolbar_tools_menu_links_discovered_alter(&$links) {
|
||||
// "Content>Comment" also has "File" as a tab then we decide to
|
||||
// set this one as parent of the added link if not the current tab
|
||||
// will be the parent.
|
||||
if (!empty($link['parent'])) {
|
||||
if (!empty($link['parent']) && isset($links[$link['parent']])) {
|
||||
$parentlink = $links[$link['parent']];
|
||||
$parentlink_route = $parentlink['route_name'];
|
||||
$parent_primary = $manager->getLocalTasks($parentlink_route, 0);
|
||||
|
||||
-4
@@ -1,4 +0,0 @@
|
||||
services:
|
||||
admin_toolbar_tools.toolbar_handler:
|
||||
class: Drupal\admin_toolbar_tools\ToolbarHandler
|
||||
arguments: ['@module_handler']
|
||||
+1
-1
@@ -44,7 +44,7 @@ class AdminToolbarToolsAlterTest extends WebTestBase {
|
||||
*/
|
||||
public function testAdminToolbarTools() {
|
||||
// Assert that special menu items are present in the HTML.
|
||||
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-help"');
|
||||
$this->assertRaw('class="toolbar-icon toolbar-icon-admin-toolbar-tools-flush"');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
-135
@@ -1,135 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\admin_toolbar_tools;
|
||||
|
||||
use Drupal\Core\DependencyInjection\ContainerInjectionInterface;
|
||||
use Drupal\Core\Extension\ModuleHandler;
|
||||
use Drupal\Core\StringTranslation\StringTranslationTrait;
|
||||
use Drupal\Core\Template\Attribute;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
|
||||
/**
|
||||
* Toolbar integration handler.
|
||||
*/
|
||||
class ToolbarHandler implements ContainerInjectionInterface {
|
||||
|
||||
use StringTranslationTrait;
|
||||
|
||||
/**
|
||||
* The module service.
|
||||
*
|
||||
* @var \Drupal\Core\Extension\ModuleHandler
|
||||
*/
|
||||
protected $moduleHandler;
|
||||
|
||||
/**
|
||||
* ToolbarHandler constructor.
|
||||
*
|
||||
* @param \Drupal\Core\Extension\ModuleHandler $module_handler
|
||||
* The module service.
|
||||
*/
|
||||
public function __construct(ModuleHandler $module_handler) {
|
||||
$this->moduleHandler = $module_handler;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('module_handler')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Lazy builder callback for the admin_toolbar_tool items.
|
||||
*
|
||||
* @return array
|
||||
* A renderable array as expected by the renderer service.
|
||||
*/
|
||||
public function lazyBuilder() {
|
||||
// Render the pre_render callback we disabled earlier.
|
||||
$build = admin_toolbar_prerender_toolbar_administration_tray([]);
|
||||
|
||||
// Add links that are uncacheable.
|
||||
// Core toolbar module calculates cachability in advance so we have to build
|
||||
// a fake menu tree here, including access checks.
|
||||
$tools_menu = &$build['administration_menu']['#items']['admin_toolbar_tools.help']['below'];
|
||||
|
||||
// Adding the 'Flush all caches' menu in the correct place.
|
||||
$menu_render_array = $this->createMenuRenderArray('admin_toolbar_tools.flush', $this->t('Flush all caches'), TRUE);
|
||||
$this->arrayInsert($tools_menu, 1, $menu_render_array);
|
||||
|
||||
// Adding the submenus to 'Flush all caches' menu.
|
||||
if (!empty($tools_menu['admin_toolbar_tools.flush'])) {
|
||||
$tools_sub_menu = &$tools_menu['admin_toolbar_tools.flush']['below'];
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.cssjs', $this->t('Flush CSS and Javascript'));
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.plugin', $this->t('Flush plugins cache'));
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_static', $this->t('Flush static cache'));
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_menu', $this->t('Flush routing and links cache'));
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_rendercache', $this->t('Flush render cache'));
|
||||
|
||||
// Adding a menu link to clean the Views cache.
|
||||
if ($this->moduleHandler->moduleExists('views')) {
|
||||
$tools_sub_menu += $this->createMenuRenderArray('admin_toolbar_tools.flush_views', $this->t('Flush views cache'));
|
||||
}
|
||||
}
|
||||
|
||||
// Adding the 'Run Cron' menu in the correct place.
|
||||
$menu_render_array = $this->createMenuRenderArray('system.run_cron', $this->t('Run cron'));
|
||||
$this->arrayInsert($tools_menu, 3, $menu_render_array);
|
||||
|
||||
return $build;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the menu render array.
|
||||
*
|
||||
* @param string $route
|
||||
* The route.
|
||||
* @param string $title
|
||||
* The menu title.
|
||||
* @param bool $submenu
|
||||
* Specify if the current menu element have a submenu.
|
||||
*
|
||||
* @return array
|
||||
* A renderable array as expected by the renderer service.
|
||||
*/
|
||||
private function createMenuRenderArray($route, $title, $submenu = FALSE) {
|
||||
$data = [];
|
||||
$url = Url::fromRoute($route);
|
||||
if ($url->access()) {
|
||||
$data[$route] = [
|
||||
'title' => $title,
|
||||
'url' => $url,
|
||||
'attributes' => new Attribute(['class' => ['menu-item'] + ($submenu ? ['menu-item--expanded'] : [])]),
|
||||
];
|
||||
if ($submenu) {
|
||||
$data[$route]['below'] = [];
|
||||
$data[$route]['is_expanded'] = TRUE;
|
||||
}
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Insert an array in a given position of another array.
|
||||
*
|
||||
* @param array $array
|
||||
* The array where we need to insert new elements.
|
||||
* @param int $position
|
||||
* The position where we will add the new array.
|
||||
* @param array $insert_array
|
||||
* The array that will be inserted.
|
||||
*
|
||||
* @see http://php.net/manual/en/function.array-splice.php#56794
|
||||
*/
|
||||
private function arrayInsert(array &$array, $position, array $insert_array) {
|
||||
// Getting the first part of the array.
|
||||
$first_array = array_splice($array, 0, $position);
|
||||
// Inserting the new part in the desired position.
|
||||
$array = array_merge($first_array, $insert_array, $array);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
background-color: #f5f5f2;
|
||||
}
|
||||
|
||||
.toolbar-tray-horizontal ul li.menu-item {
|
||||
.toolbar-tray-horizontal ul li li.menu-item {
|
||||
border-top: none transparent;
|
||||
border-right: 1px solid #dddddd;
|
||||
border-bottom: 1px solid #dddddd;
|
||||
|
||||
@@ -1,50 +1,53 @@
|
||||
(function ($) {
|
||||
$(document).ready(function () {
|
||||
$('a.toolbar-icon').removeAttr('title');
|
||||
Drupal.behaviors.adminToolbar = {
|
||||
attach: function (context, settings) {
|
||||
|
||||
$('.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item').hoverIntent({
|
||||
over: function () {
|
||||
// At the current depth, we should delete all "hover-intent" classes.
|
||||
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
|
||||
$(this).parent().find('li').removeClass('hover-intent');
|
||||
$(this).addClass('hover-intent');
|
||||
},
|
||||
out: function () {
|
||||
$(this).removeClass('hover-intent');
|
||||
},
|
||||
timeout: 250
|
||||
});
|
||||
|
||||
// Make the toolbar menu navigable with keyboard.
|
||||
$('ul.toolbar-menu li.menu-item--expanded a').on('focusin', function () {
|
||||
$('li.menu-item--expanded').removeClass('hover-intent');
|
||||
$(this).parents('li.menu-item--expanded').addClass('hover-intent');
|
||||
});
|
||||
|
||||
$('ul.toolbar-menu li.menu-item a').keydown(function (e) {
|
||||
if ((e.shiftKey && (e.keyCode || e.which) == 9)) {
|
||||
if ($(this).parent('.menu-item').prev().hasClass('menu-item--expanded')) {
|
||||
$(this).parent('.menu-item').prev().addClass('hover-intent');
|
||||
$('a.toolbar-icon', context).removeAttr('title');
|
||||
|
||||
$('.toolbar-tray-horizontal li.menu-item--expanded, .toolbar-tray-horizontal ul li.menu-item--expanded .menu-item', context).hoverIntent({
|
||||
over: function () {
|
||||
// At the current depth, we should delete all "hover-intent" classes.
|
||||
// Other wise we get unwanted behaviour where menu items are expanded while already in hovering other ones.
|
||||
$(this).parent().find('li').removeClass('hover-intent');
|
||||
$(this).addClass('hover-intent');
|
||||
},
|
||||
out: function () {
|
||||
$(this).removeClass('hover-intent');
|
||||
},
|
||||
timeout: 250
|
||||
});
|
||||
|
||||
// Make the toolbar menu navigable with keyboard.
|
||||
$('ul.toolbar-menu li.menu-item--expanded a', context).on('focusin', function () {
|
||||
$('li.menu-item--expanded', context).removeClass('hover-intent');
|
||||
$(this).parents('li.menu-item--expanded').addClass('hover-intent');
|
||||
});
|
||||
|
||||
$('ul.toolbar-menu li.menu-item a', context).keydown(function (e) {
|
||||
if ((e.shiftKey && (e.keyCode || e.which) == 9)) {
|
||||
if ($(this).parent('.menu-item').prev().hasClass('menu-item--expanded')) {
|
||||
$(this).parent('.menu-item').prev().addClass('hover-intent');
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
$('.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a', context).on('focusin', function () {
|
||||
$('.menu-item--expanded').removeClass('hover-intent');
|
||||
});
|
||||
|
||||
$('.toolbar-menu:first-child > .menu-item', context).on('hover', function () {
|
||||
$(this,'a').css("background: #fff;");
|
||||
});
|
||||
|
||||
$('ul:not(.toolbar-menu)', context).on({
|
||||
mousemove: function () {
|
||||
$('li.menu-item--expanded').removeClass('hover-intent');
|
||||
},
|
||||
hover: function () {
|
||||
$('li.menu-item--expanded').removeClass('hover-intent');
|
||||
}
|
||||
});
|
||||
|
||||
$('.toolbar-menu:first-child > .menu-item:not(.menu-item--expanded) a, .toolbar-tab > a').on('focusin', function () {
|
||||
$('.menu-item--expanded').removeClass('hover-intent');
|
||||
});
|
||||
|
||||
$('.toolbar-menu:first-child > .menu-item').on('hover', function () {
|
||||
$(this,'a').css("background: #fff;");
|
||||
});
|
||||
|
||||
$('ul:not(.toolbar-menu)').on({
|
||||
mousemove: function () {
|
||||
$('li.menu-item--expanded').removeClass('hover-intent');
|
||||
},
|
||||
hover: function () {
|
||||
$('li.menu-item--expanded').removeClass('hover-intent');
|
||||
}
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
};
|
||||
})(jQuery);
|
||||
|
||||
@@ -5,8 +5,8 @@ description: 'Provides basic revert and update functionality for other modules'
|
||||
dependencies:
|
||||
- drupal:config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-09-18
|
||||
version: '8.x-1.4'
|
||||
# Information added by Drupal.org packaging script on 2017-12-05
|
||||
version: '8.x-1.5'
|
||||
core: '8.x'
|
||||
project: 'config_update'
|
||||
datestamp: 1505755746
|
||||
datestamp: 1512514387
|
||||
|
||||
+3
-3
@@ -7,8 +7,8 @@ dependencies:
|
||||
- config_update:config_update
|
||||
- drupal:config
|
||||
|
||||
# Information added by Drupal.org packaging script on 2017-09-18
|
||||
version: '8.x-1.4'
|
||||
# Information added by Drupal.org packaging script on 2017-12-05
|
||||
version: '8.x-1.5'
|
||||
core: '8.x'
|
||||
project: 'config_update'
|
||||
datestamp: 1505755746
|
||||
datestamp: 1512514387
|
||||
|
||||
+1
-3
@@ -12,9 +12,7 @@ config_update_ui.import:
|
||||
path: '/admin/config/development/configuration/report/import/{config_type}/{config_name}'
|
||||
defaults:
|
||||
_title: 'Import'
|
||||
_controller: '\Drupal\config_update_ui\Controller\ConfigUpdateController::import'
|
||||
config_type: NULL
|
||||
config_name: NULL
|
||||
_form: '\Drupal\config_update_ui\Form\ConfigImportConfirmForm'
|
||||
requirements:
|
||||
_permission: 'import configuration'
|
||||
|
||||
|
||||
-20
@@ -112,26 +112,6 @@ class ConfigUpdateController extends ControllerBase {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Imports configuration from a module, theme, or profile.
|
||||
*
|
||||
* Configuration is assumed not to currently exist.
|
||||
*
|
||||
* @param string $config_type
|
||||
* The type of configuration.
|
||||
* @param string $config_name
|
||||
* The name of the config item, without the prefix.
|
||||
*
|
||||
* @return \Symfony\Component\HttpFoundation\RedirectResponse
|
||||
* Redirects to the updates report.
|
||||
*/
|
||||
public function import($config_type, $config_name) {
|
||||
$this->configRevert->import($config_type, $config_name);
|
||||
|
||||
drupal_set_message($this->t('The configuration was imported.'));
|
||||
return $this->redirect('config_update_ui.report');
|
||||
}
|
||||
|
||||
/**
|
||||
* Shows the diff between active and provided configuration.
|
||||
*
|
||||
|
||||
+12
-11
@@ -8,6 +8,7 @@ use Drupal\Core\Url;
|
||||
use Drupal\config_update\ConfigListInterface;
|
||||
use Drupal\config_update\ConfigRevertInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Defines a confirmation form for deleting configuration.
|
||||
@@ -81,9 +82,20 @@ class ConfigDeleteConfirmForm extends ConfirmFormBase {
|
||||
}
|
||||
else {
|
||||
$definition = $this->configList->getType($this->type);
|
||||
if (!$definition) {
|
||||
// Make a 404 error if the type doesn't exist.
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$type_label = $definition->get('label');
|
||||
}
|
||||
|
||||
// To delete, the configuration item must exist in active storage. Check
|
||||
// that and make a 404 error if not.
|
||||
$active = $this->configRevert->getFromActive($this->type, $this->name);
|
||||
if (!$active) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
return $this->t('Are you sure you want to delete the %type config %item?', ['%type' => $type_label, '%item' => $this->name]);
|
||||
}
|
||||
|
||||
@@ -119,17 +131,6 @@ class ConfigDeleteConfirmForm extends ConfirmFormBase {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$value = $this->configRevert->getFromActive($this->type, $this->name);
|
||||
if (!$value) {
|
||||
$form_state->setErrorByName('', $this->t('There is no configuration @type named @name to delete', ['@type' => $this->type, '@name' => $this->name]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
+146
@@ -0,0 +1,146 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\config_update_ui\Form;
|
||||
|
||||
use Drupal\Core\Form\ConfirmFormBase;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\config_update\ConfigListInterface;
|
||||
use Drupal\config_update\ConfigRevertInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Defines a confirmation form for importing configuration.
|
||||
*/
|
||||
class ConfigImportConfirmForm extends ConfirmFormBase {
|
||||
|
||||
/**
|
||||
* The type of config being imported.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $type;
|
||||
|
||||
/**
|
||||
* The name of the config item being imported, without the prefix.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $name;
|
||||
|
||||
/**
|
||||
* The config lister.
|
||||
*
|
||||
* @var \Drupal\config_update\ConfigListInterface
|
||||
*/
|
||||
protected $configList;
|
||||
|
||||
/**
|
||||
* The config reverter.
|
||||
*
|
||||
* @var \Drupal\config_update\ConfigRevertInterface
|
||||
*/
|
||||
protected $configRevert;
|
||||
|
||||
/**
|
||||
* Constructs a ConfigImportConfirmForm object.
|
||||
*
|
||||
* @param \Drupal\config_update\ConfigListInterface $config_list
|
||||
* The config lister.
|
||||
* @param \Drupal\config_update\ConfigRevertInterface $config_update
|
||||
* The config reverter.
|
||||
*/
|
||||
public function __construct(ConfigListInterface $config_list, ConfigRevertInterface $config_update) {
|
||||
$this->configList = $config_list;
|
||||
$this->configRevert = $config_update;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function create(ContainerInterface $container) {
|
||||
return new static(
|
||||
$container->get('config_update.config_list'),
|
||||
$container->get('config_update.config_update')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFormId() {
|
||||
return 'config_import_confirm';
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getQuestion() {
|
||||
if ($this->type == 'system.simple') {
|
||||
$type_label = $this->t('Simple configuration');
|
||||
}
|
||||
else {
|
||||
$definition = $this->configList->getType($this->type);
|
||||
if (!$definition) {
|
||||
// Make a 404 error if the type doesn't exist.
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$type_label = $definition->get('label');
|
||||
}
|
||||
|
||||
// To import (as opposed to revert), the configuration item must exist in
|
||||
// extension storage but not active storage, so check that, and make a 404
|
||||
// error if not.
|
||||
$extension = $this->configRevert->getFromExtension($this->type, $this->name);
|
||||
$active = $this->configRevert->getFromActive($this->type, $this->name);
|
||||
if (!$extension || $active) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
return $this->t('Are you sure you want to import the %type config %item from its source configuration?', ['%type' => $type_label, '%item' => $this->name]);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getCancelUrl() {
|
||||
return new Url('config_update_ui.report');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getDescription() {
|
||||
return $this->t('Configuration will be added to your site. This action cannot be undone.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getConfirmText() {
|
||||
return $this->t('Import');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildForm(array $form, FormStateInterface $form_state, $config_type = NULL, $config_name = NULL) {
|
||||
$this->type = $config_type;
|
||||
$this->name = $config_name;
|
||||
|
||||
$form = parent::buildForm($form, $form_state);
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function submitForm(array &$form, FormStateInterface $form_state) {
|
||||
$this->configRevert->import($this->type, $this->name);
|
||||
|
||||
drupal_set_message($this->t('The configuration was imported from its source.'));
|
||||
$form_state->setRedirectUrl($this->getCancelUrl());
|
||||
}
|
||||
|
||||
}
|
||||
+14
-11
@@ -8,6 +8,7 @@ use Drupal\Core\Url;
|
||||
use Drupal\config_update\ConfigListInterface;
|
||||
use Drupal\config_update\ConfigRevertInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
|
||||
|
||||
/**
|
||||
* Defines a confirmation form for reverting configuration.
|
||||
@@ -81,9 +82,22 @@ class ConfigRevertConfirmForm extends ConfirmFormBase {
|
||||
}
|
||||
else {
|
||||
$definition = $this->configList->getType($this->type);
|
||||
if (!$definition) {
|
||||
// Make a 404 error if the type doesn't exist.
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
$type_label = $definition->get('label');
|
||||
}
|
||||
|
||||
// To revert (as opposed to import), the configuration item must exist in
|
||||
// both active storage and extension storage, so check that and make a 404
|
||||
// error if not.
|
||||
$extension = $this->configRevert->getFromExtension($this->type, $this->name);
|
||||
$active = $this->configRevert->getFromActive($this->type, $this->name);
|
||||
if (!$extension || !$active) {
|
||||
throw new NotFoundHttpException();
|
||||
}
|
||||
|
||||
return $this->t('Are you sure you want to revert the %type config %item to its source configuration?', ['%type' => $type_label, '%item' => $this->name]);
|
||||
}
|
||||
|
||||
@@ -119,17 +133,6 @@ class ConfigRevertConfirmForm extends ConfirmFormBase {
|
||||
return $form;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validateForm(array &$form, FormStateInterface $form_state) {
|
||||
$value = $this->configRevert->getFromExtension($this->type, $this->name);
|
||||
if (!$value) {
|
||||
$form_state->setErrorByName('', $this->t('There is no configuration @type named @name to import', ['@type' => $this->type, '@name' => $this->name]));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
||||
+15
@@ -106,6 +106,11 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertText('Testing profile');
|
||||
$this->assertDrushReports('profile', '', [], [], [], array_keys($inactive));
|
||||
|
||||
// Verify that the user search page cannot be imported (because it already
|
||||
// exists).
|
||||
$this->drupalGet('admin/config/development/configuration/report/import/search_page/user_search');
|
||||
$this->assertResponse(404);
|
||||
|
||||
// Delete the user search page from the search UI and verify report for
|
||||
// both the search page config type and user module.
|
||||
$this->drupalGet('admin/config/search/pages');
|
||||
@@ -130,10 +135,19 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
'views.view.who_s_online',
|
||||
], ['changed']);
|
||||
|
||||
// Verify that the user search page cannot be reverted (because it does
|
||||
// not already exist).
|
||||
$this->drupalGet('admin/config/development/configuration/report/revert/search_page/user_search');
|
||||
$this->assertResponse(404);
|
||||
// Verify that the delete URL doesn't work either.
|
||||
$this->drupalGet('admin/config/development/configuration/report/delete/search_page/user_search');
|
||||
$this->assertResponse(404);
|
||||
|
||||
// Use the import link to get it back. Do this from the search page
|
||||
// report to make sure we are importing the right config.
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->clickLink('Import from source');
|
||||
$this->drupalPostForm(NULL, [], 'Import');
|
||||
$this->assertText('The configuration was imported');
|
||||
$this->assertNoReport();
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
@@ -277,6 +291,7 @@ class ConfigUpdateTest extends WebTestBase {
|
||||
$this->assertText('cannot be undone');
|
||||
$this->drupalPostForm(NULL, [], 'Delete');
|
||||
$this->assertText('The configuration was deleted');
|
||||
|
||||
// And verify the report again.
|
||||
$this->drupalGet('admin/config/development/configuration/report/type/search_page');
|
||||
$this->assertReport('Search page', [], [], [], []);
|
||||
|
||||
@@ -123,7 +123,7 @@ class ConfigLister implements ConfigListInterface {
|
||||
public function getTypeNameByConfigName($name) {
|
||||
$definitions = $this->listTypes();
|
||||
foreach ($this->typesByPrefix as $prefix => $entity_type) {
|
||||
if (strpos($name, $prefix) === 0) {
|
||||
if (strpos($name, $prefix . '.') === 0) {
|
||||
return $entity_type;
|
||||
}
|
||||
}
|
||||
@@ -174,6 +174,12 @@ class ConfigLister implements ConfigListInterface {
|
||||
break;
|
||||
}
|
||||
|
||||
// This only seems to be a problem in unit tests, where a mock object
|
||||
// is returning NULL instead of an empy array for some reason.
|
||||
if (!is_array($optional_list)) {
|
||||
$optional_list = [];
|
||||
}
|
||||
|
||||
return [$active_list, $install_list, $optional_list];
|
||||
}
|
||||
|
||||
@@ -211,7 +217,7 @@ class ConfigLister implements ConfigListInterface {
|
||||
$list = array_combine($list, $list);
|
||||
foreach ($list as $name) {
|
||||
foreach ($prefixes as $prefix) {
|
||||
if (strpos($name, $prefix) === 0) {
|
||||
if (strpos($name, $prefix . '.') === 0) {
|
||||
unset($list[$name]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,265 @@
|
||||
<?php
|
||||
|
||||
namespace Drupal\Tests\config_update\Unit;
|
||||
|
||||
use Drupal\config_update\ConfigLister;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
* Tests the \Drupal\config_update\ConfigLister class.
|
||||
*
|
||||
* @group config_update
|
||||
*
|
||||
* @coversDefaultClass \Drupal\config_update\ConfigLister
|
||||
*/
|
||||
class ConfigListerTest extends UnitTestCase {
|
||||
|
||||
/**
|
||||
* The config lister to test.
|
||||
*
|
||||
* @var \Drupal\config_update\ConfigLister
|
||||
*/
|
||||
protected $configLister;
|
||||
|
||||
/**
|
||||
* The mocked entity definition information.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $entityDefinitionInformation;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->configLister = new ConfigLister($this->getEntityManagerMock(), $this->getConfigStorageMock('active'), $this->getConfigStorageMock('extension'), $this->getConfigStorageMock('optional'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock entity manager for the test.
|
||||
*/
|
||||
protected function getEntityManagerMock() {
|
||||
// Make a list of fake entity definitions. Make sure they are not sorted,
|
||||
// to test that the methods sort them. Also make sure there are a couple
|
||||
// with prefixes that are subsets of each other.
|
||||
$this->entityDefinitionInformation = [
|
||||
['prefix' => 'foo.bar', 'type' => 'foo'],
|
||||
['prefix' => 'foo.barbaz', 'type' => 'bar'],
|
||||
['prefix' => 'baz.foo', 'type' => 'baz'],
|
||||
];
|
||||
|
||||
$definitions = [];
|
||||
foreach ($this->entityDefinitionInformation as $info) {
|
||||
$def = $this->getMockBuilder('Drupal\Core\Config\Entity\ConfigEntityTypeInterface')->getMock();
|
||||
$def
|
||||
->expects($this->any())
|
||||
->method('getConfigPrefix')
|
||||
->willReturn($info['prefix']);
|
||||
$def
|
||||
->expects($this->any())
|
||||
->method('isSubclassOf')
|
||||
->willReturn(TRUE);
|
||||
|
||||
$def->getConfigPrefix();
|
||||
|
||||
$definitions[$info['type']] = $def;
|
||||
}
|
||||
|
||||
$manager = $this->getMockBuilder('Drupal\Core\Entity\EntityTypeManagerInterface')->getMock();
|
||||
$manager
|
||||
->method('getDefinitions')
|
||||
->willReturn($definitions);
|
||||
|
||||
return($manager);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a mock config storage object for the test.
|
||||
*
|
||||
* @param string $type
|
||||
* Type of storage object to return: 'active', 'extension', or 'optional'.
|
||||
*/
|
||||
protected function getConfigStorageMock($type) {
|
||||
if ($type == 'active') {
|
||||
$storage = $this->getMockBuilder('Drupal\Core\Config\StorageInterface')->getMock();
|
||||
|
||||
// The only use of the read() method on active storage is
|
||||
// with the core.extension config, to get the profile name.
|
||||
$storage
|
||||
->method('read')
|
||||
->willReturn(['profile' => 'standard']);
|
||||
|
||||
$map = [
|
||||
['foo.bar', ['foo.bar.one', 'foo.bar.two', 'foo.bar.three']],
|
||||
['foo.barbaz', ['foo.barbaz.four', 'foo.barbaz.five', 'foo.barbaz.six']],
|
||||
['baz.foo'], [],
|
||||
['',
|
||||
[
|
||||
'foo.bar.one',
|
||||
'foo.bar.two',
|
||||
'foo.bar.three',
|
||||
'foo.barbaz.four',
|
||||
'foo.barbaz.five',
|
||||
'foo.barbaz.six',
|
||||
'something.else',
|
||||
'another.one',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$storage
|
||||
->method('listAll')
|
||||
->will($this->returnValueMap($map));
|
||||
}
|
||||
elseif ($type == 'extension') {
|
||||
$storage = $this->getMockBuilder('Drupal\Core\Config\ExtensionInstallStorage')->disableOriginalConstructor()->getMock();
|
||||
$storage
|
||||
->method('getComponentNames')
|
||||
->willReturn([
|
||||
'foo.bar.one' => 'ignored',
|
||||
'foo.bar.two' => 'ignored',
|
||||
'foo.bar.seven' => 'ignored',
|
||||
'foo.barnot.three' => 'ignored',
|
||||
'something.else' => 'ignored',
|
||||
]);
|
||||
|
||||
$map = [
|
||||
['foo.bar', ['foo.bar.one', 'foo.bar.two', 'foo.bar.seven']],
|
||||
['baz.foo'], [],
|
||||
['',
|
||||
[
|
||||
'foo.bar.one',
|
||||
'foo.bar.two',
|
||||
'foo.bar.seven',
|
||||
'foo.barbaz.four',
|
||||
'foo.barnot.three',
|
||||
'something.else',
|
||||
],
|
||||
],
|
||||
];
|
||||
|
||||
$storage
|
||||
->method('listAll')
|
||||
->will($this->returnValueMap($map));
|
||||
}
|
||||
else {
|
||||
$storage = $this->getMockBuilder('Drupal\Core\Config\ExtensionInstallStorage')->disableOriginalConstructor()->getMock();
|
||||
$storage
|
||||
->method('getComponentNames')
|
||||
->willReturn([
|
||||
'foo.barbaz.four' => 'ignored',
|
||||
]);
|
||||
|
||||
$map = [
|
||||
['foo.bar'], [],
|
||||
['foo.barbaz', ['foo.barbaz.four']],
|
||||
['', ['foo.barbaz.four']],
|
||||
];
|
||||
$storage
|
||||
->method('listAll')
|
||||
->will($this->returnValueMap($map));
|
||||
}
|
||||
return $storage;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Drupal\config_update\ConfigLister::listConfig
|
||||
* @dataProvider listConfigProvider
|
||||
*/
|
||||
public function testListConfig($a, $b, $expected) {
|
||||
$this->assertEquals($expected, $this->configLister->listConfig($a, $b));
|
||||
}
|
||||
|
||||
/**
|
||||
* Data provider for self:testListConfig().
|
||||
*/
|
||||
public function listConfigProvider() {
|
||||
return [
|
||||
// Arguments are $list_type, $name.
|
||||
// We cannot really test the extension types here, because they rely
|
||||
// on the going out to the file system to find out what config objects
|
||||
// are there. This is too complex to mock. It is tested in the tests for
|
||||
// the report output in the config_update_ui module tests. Anyway, we
|
||||
// can test the other types.
|
||||
['type', 'system.all',
|
||||
[
|
||||
[
|
||||
'foo.bar.one',
|
||||
'foo.bar.two',
|
||||
'foo.bar.three',
|
||||
'foo.barbaz.four',
|
||||
'foo.barbaz.five',
|
||||
'foo.barbaz.six',
|
||||
'something.else',
|
||||
'another.one',
|
||||
],
|
||||
[
|
||||
'foo.bar.one',
|
||||
'foo.bar.two',
|
||||
'foo.bar.seven',
|
||||
'foo.barbaz.four',
|
||||
'foo.barnot.three',
|
||||
'something.else',
|
||||
],
|
||||
['foo.barbaz.four'],
|
||||
],
|
||||
],
|
||||
['type', 'system.simple',
|
||||
[
|
||||
['something.else', 'another.one'],
|
||||
['foo.barnot.three', 'something.else'],
|
||||
[],
|
||||
],
|
||||
],
|
||||
['type', 'foo',
|
||||
[
|
||||
['foo.bar.one', 'foo.bar.two', 'foo.bar.three'],
|
||||
['foo.bar.one', 'foo.bar.two', 'foo.bar.seven'],
|
||||
[],
|
||||
],
|
||||
],
|
||||
['type', 'unknown.type', [[], [], []]],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Drupal\config_update\ConfigLister::getType
|
||||
*/
|
||||
public function testGetType() {
|
||||
$return = $this->configLister->getType('not_in_list');
|
||||
$this->assertNull($return);
|
||||
|
||||
foreach ($this->entityDefinitionInformation as $info) {
|
||||
$return = $this->configLister->getType($info['type']);
|
||||
$this->assertEquals($return->getConfigPrefix(), $info['prefix']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Drupal\config_update\ConfigLister::getTypeByPrefix
|
||||
*/
|
||||
public function testGetTypeByPrefix() {
|
||||
$return = $this->configLister->getTypeByPrefix('not_in_list');
|
||||
$this->assertNull($return);
|
||||
|
||||
foreach ($this->entityDefinitionInformation as $info) {
|
||||
$return = $this->configLister->getTypeByPrefix($info['prefix']);
|
||||
$this->assertEquals($return->getConfigPrefix(), $info['prefix']);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @covers \Drupal\config_update\ConfigLister::getTypeNameByConfigName
|
||||
*/
|
||||
public function testGetTypeNameByConfigName() {
|
||||
$return = $this->configLister->getTypeNameByConfigName('not_in_list');
|
||||
$this->assertNull($return);
|
||||
|
||||
foreach ($this->entityDefinitionInformation as $info) {
|
||||
$return = $this->configLister->getTypeNameByConfigName($info['prefix'] . '.something');
|
||||
$this->assertEquals($return, $info['type']);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user