Commit cd635205 authored by alexpott's avatar alexpott

Issue #2085571 by Xano, dawehner: Fixed admin/content should not depend on node.module.

parent e1351af7
......@@ -16,7 +16,7 @@ comment.confirm_delete_tab:
comment.admin:
title: Comments
route_name: comment.admin
base_route: node.content_overview
base_route: system.admin_content
comment.admin_new:
title: 'Published comments'
......
comment.admin:
title: Comments
route_name: comment.admin
parent: system.admin
parent: system.admin_content
description: 'List and edit site comments and the comment approval queue.'
comment.bundle_list:
title: 'Comment forms'
......
......@@ -183,19 +183,6 @@ function comment_theme() {
);
}
/**
* Implements hook_menu_link_defaults_alter()
*/
function comment_menu_link_defaults_alter(&$links) {
if (isset($links['node.content_overview'])) {
// Add comments to the description for admin/content if any.
$links['node.content_overview']['description'] = 'Administer content and comments.';
}
if (\Drupal::moduleHandler()->moduleExists('node')) {
$links['comment.admin']['parent'] = 'node.content_overview';
}
}
/**
* Returns a menu title which includes the number of unapproved comments.
*
......
......@@ -7,4 +7,4 @@ node.add_page:
route_name: node.add_page
title: 'Add content'
appears_on:
- node.content_overview
- system.admin_content
......@@ -11,10 +11,6 @@ node.delete_confirm:
base_route: node.view
title: Delete
weight: 10
node.content_overview:
title: Content
route_name: node.content_overview
base_route: node.content_overview
node.revision_overview:
route_name: node.revision_overview
base_route: node.view
......
node.content_overview:
title: Content
route_name: node.content_overview
parent: system.admin
description: 'Find and manage content.'
weight: -10
node.overview_types:
title: 'Content types'
parent: system.admin_structure
......
......@@ -117,7 +117,7 @@ function node_help($route_name, Request $request) {
$output .= '<dt>' . t('Creating custom content types') . '</dt>';
$output .= '<dd>' . t('The Node module gives users with the <em>Administer content types</em> permission the ability to <a href="!content-new">create new content types</a> in addition to the default ones already configured. Creating custom content types allows you the flexibility to add <a href="!field">fields</a> and configure default settings that suit the differing needs of various site content.', array('!content-new' => \Drupal::url('node.type_add'), '!field' => \Drupal::url('help.page', array('name' => 'field')))) . '</dd>';
$output .= '<dt>' . t('Administering content') . '</dt>';
$output .= '<dd>' . t('The <a href="!content">Content administration page</a> allows you to review and bulk manage your site content.', array('!content' => \Drupal::url('node.content_overview'))) . '</dd>';
$output .= '<dd>' . t('The <a href="!content">Content administration page</a> allows you to review and bulk manage your site content.', array('!content' => \Drupal::url('system.admin_content'))) . '</dd>';
$output .= '<dt>' . t('Creating revisions') . '</dt>';
$output .= '<dd>' . t('The Node module also enables you to create multiple versions of any content, and revert to older versions using the <em>Revision information</em> settings.') . '</dd>';
$output .= '<dt>' . t('User permissions') . '</dt>';
......
node.content_overview:
path: '/admin/content'
defaults:
_title: 'Content'
_entity_list: 'node'
requirements:
_permission: 'access content overview'
node.multiple_delete_confirm:
path: '/admin/content/node/delete'
......
services:
node.route_subscriber:
class: Drupal\node\Routing\RouteSubscriber
tags:
- { name: event_subscriber }
node.grant_storage:
class: Drupal\node\NodeGrantDatabaseStorage
arguments: ['@database', '@module_handler']
......
......@@ -125,7 +125,7 @@ public function submitForm(array &$form, array &$form_state) {
drupal_set_message(format_plural($count, 'Deleted 1 post.', 'Deleted @count posts.'));
Cache::invalidateTags(array('content' => TRUE));
}
$form_state['redirect_route']['route_name'] = 'node.content_overview';
$form_state['redirect_route']['route_name'] = 'system.admin_content';
}
}
<?php
/**
* @file
* Contains \Drupal\node\Routing\RouteSubscriber.
*/
namespace Drupal\node\Routing;
use Drupal\Core\Routing\RouteSubscriberBase;
use Symfony\Component\Routing\RouteCollection;
/**
* Listens to the dynamic route events.
*/
class RouteSubscriber extends RouteSubscriberBase {
/**
* {@inheritdoc}
*/
protected function alterRoutes(RouteCollection $collection) {
// As nodes are the primary type of content, the node listing should be
// easily available. In order to do that, override admin/content to show
// a node listing instead of the path's child links.
$route = $collection->get('system.admin_content');
if ($route) {
$route->setDefaults(array(
'_title' => 'Content',
'_entity_list' => 'node',
));
$route->setRequirements(array(
'_permission' => 'access content overview',
));
}
}
}
......@@ -94,18 +94,21 @@ public static function create(ContainerInterface $container) {
/**
* Provide the administration overview page.
*
* @param string $path
* The administrative path for which to display child links.
*
* @return array
* A renderable array of the administration overview page.
*/
public function overview() {
public function overview($path) {
// Check for status report errors.
if ($this->systemManager->checkRequirements() && $this->currentUser()->hasPermission('administer site configuration')) {
drupal_set_message($this->t('One or more problems were detected with your Drupal installation. Check the <a href="@status">status report</a> for more information.', array('@status' => url('admin/reports/status'))), 'error');
}
$blocks = array();
// Load all links on admin/config and menu links below it.
// Load all links on $path and menu links below it.
$query = $this->queryFactory->get('menu_link')
->condition('link_path', 'admin/config')
->condition('link_path', $path)
->condition('module', 'system');
$result = $query->execute();
$menu_link_storage = $this->entityManager()->getStorage('menu_link');
......
......@@ -8,17 +8,46 @@
namespace Drupal\system\Plugin\Derivative;
use Drupal\Component\Plugin\Derivative\DerivativeBase;
use Drupal\Core\Extension\ThemeHandlerInterface;
use Drupal\Core\Plugin\Discovery\ContainerDerivativeInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
* Provides dynamic tabs based on active themes.
*/
class ThemeLocalTask extends DerivativeBase {
class ThemeLocalTask extends DerivativeBase implements ContainerDerivativeInterface {
/**
* The theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface
*/
protected $themeHandler;
/**
* Constructs a new ThemeLocalTask instance.
*
* @param \Drupal\Core\Extension\ThemeHandlerInterface $theme_handler
* The theme handler.
*/
public function __construct(ThemeHandlerInterface $theme_handler) {
$this->themeHandler = $theme_handler;
}
/**
* {@inheritdoc}
*/
public static function create(ContainerInterface $container, $base_plugin_id) {
return new static(
$container->get('theme_handler')
);
}
/**
* {@inheritdoc}
*/
public function getDerivativeDefinitions($base_plugin_definition) {
foreach (list_themes() as $theme_name => $theme) {
foreach ($this->themeHandler->listInfo() as $theme_name => $theme) {
if ($theme->status) {
$this->derivatives[$theme_name] = $base_plugin_definition;
$this->derivatives[$theme_name]['title'] = $theme->info['name'];
......
......@@ -63,3 +63,8 @@ system.date_format_edit:
title: 'Edit'
route_name: system.date_format_edit
base_route: system.date_format_edit
system.admin_content:
title: Content
route_name: system.admin_content
base_route: system.admin_content
......@@ -3,6 +3,12 @@ system.admin:
route_name: system.admin
weight: 9
menu_name: admin
system.admin_content:
title: Content
description: 'Find and manage content.'
route_name: system.admin_content
parent: system.admin
weight: -10
system.admin_structure:
route_name: system.admin_structure
parent: system.admin
......
......@@ -382,6 +382,7 @@ system.admin_config:
path: '/admin/config'
defaults:
_content: '\Drupal\system\Controller\SystemController::overview'
path: 'admin/config'
_title: 'Configuration'
requirements:
_permission: 'access administration pages'
......@@ -408,3 +409,12 @@ system.batch_page.json:
system.update:
path: '/core/update.php'
system.admin_content:
path: '/admin/content'
defaults:
_content: '\Drupal\system\Controller\SystemController::overview'
path: 'admin/content'
_title: 'Content'
requirements:
_permission: 'access administration pages'
<?php
/**
* @file
* Contains \Drupal\system\Tests\Menu\SystemLocalTasksTest.
*/
namespace Drupal\system\Tests\Menu;
use Drupal\Core\Extension\Extension;
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTest;
/**
* Tests existence of system local tasks.
*
* @group Drupal
* @group System
*/
class SystemLocalTasksTest extends LocalTaskIntegrationTest {
/**
* The mocked theme handler.
*
* @var \Drupal\Core\Extension\ThemeHandlerInterface|\PHPUnit_Framework_MockObject_MockObject
*/
protected $themeHandler;
/**
* {@inheritdoc}
*/
public static function getInfo() {
return array(
'name' => 'System local tasks',
'description' => '',
'group' => 'System',
);
}
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->directoryList = array(
'system' => 'core/modules/system',
);
$this->themeHandler = $this->getMock('Drupal\Core\Extension\ThemeHandlerInterface');
$theme = new Extension('theme', DRUPAL_ROOT . '/core/themes/bartik', 'bartik.info.yml');
$theme->status = 1;
$theme->info = array('name' => 'bartik');
$this->themeHandler->expects($this->any())
->method('listInfo')
->will($this->returnValue(array(
'bartik' => $theme,
)));
$this->container->set('theme_handler', $this->themeHandler);
}
/**
* Tests local task existence.
*
* @dataProvider getSystemAdminRoutes
*/
public function testSystemAdminLocalTasks($route, $expected) {
$this->assertLocalTasks($route, $expected);
}
/**
* Provides a list of routes to test.
*/
public function getSystemAdminRoutes() {
return array(
array('system.admin_content', array(array('system.admin_content'))),
array('system.theme_settings_theme', array(
array('system.themes_page', 'system.theme_settings'),
array('system.theme_settings_global', 'system.theme_settings_theme:bartik'),
)),
);
}
}
......@@ -40,11 +40,22 @@ abstract class LocalTaskIntegrationTest extends UnitTestCase {
*/
protected $moduleHandler;
/**
* The container.
*
* @var \Symfony\Component\DependencyInjection\ContainerBuilder
*/
protected $container;
/**
* {@inheritdoc}
*/
protected function setUp() {
$container = new ContainerBuilder();
$config_factory = $this->getConfigFactoryStub(array());
$container->set('config.factory', $config_factory);
\Drupal::setContainer($container);
$this->container = $container;
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment