Issue #2107533 by tim.plunkett, dawehner, pwolanin, Berdir: Remove {menu_router}.
parent
3ae51ab618
commit
8608fed622
|
@ -326,7 +326,7 @@ services:
|
|||
arguments: ['@router.dumper', '@lock', '@event_dispatcher', '@module_handler', '@controller_resolver', '@state']
|
||||
router.rebuild_subscriber:
|
||||
class: Drupal\Core\EventSubscriber\RouterRebuildSubscriber
|
||||
arguments: ['@router.builder']
|
||||
arguments: ['@router.builder', '@lock']
|
||||
tags:
|
||||
- { name: event_subscriber }
|
||||
path.alias_manager.cached:
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -5,8 +5,9 @@
|
|||
* Functions to handle paths in Drupal.
|
||||
*/
|
||||
|
||||
use Drupal\Component\Utility\Url;
|
||||
use Drupal\Core\ParamConverter\ParamNotConvertedException;
|
||||
use Drupal\Core\Routing\RequestHelper;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
/**
|
||||
* Check if the current page is the front page.
|
||||
|
@ -183,57 +184,42 @@ function path_get_admin_paths() {
|
|||
/**
|
||||
* Checks a path exists and the current user has access to it.
|
||||
*
|
||||
* @param $path
|
||||
* @param string $path
|
||||
* The path to check.
|
||||
* @param $dynamic_allowed
|
||||
* Whether paths with menu wildcards (like user/%) should be allowed.
|
||||
*
|
||||
* @return
|
||||
* @return bool
|
||||
* TRUE if it is a valid path AND the current user has access permission,
|
||||
* FALSE otherwise.
|
||||
*/
|
||||
function drupal_valid_path($path, $dynamic_allowed = FALSE) {
|
||||
global $menu_admin;
|
||||
function drupal_valid_path($path) {
|
||||
// External URLs and the front page are always valid.
|
||||
if ($path == '<front>' || Url::isExternal($path)) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
// Check the routing system.
|
||||
$collection = \Drupal::service('router.route_provider')->getRoutesByPattern('/' . $path);
|
||||
if ($collection->count() == 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
$request = RequestHelper::duplicate(\Drupal::request(), '/' . $path);
|
||||
$request->attributes->set('_system_path', $path);
|
||||
|
||||
// We indicate that a menu administrator is running the menu access check.
|
||||
$menu_admin = TRUE;
|
||||
/** @var $route_provider \Drupal\Core\Routing\RouteProviderInterface */
|
||||
$route_provider = \Drupal::service('router.route_provider');
|
||||
$request->attributes->set('_menu_admin', TRUE);
|
||||
|
||||
if ($dynamic_allowed && preg_match('/\/\%/', $path)) {
|
||||
$router_path = '/' . str_replace('%', '{}', $path);
|
||||
// Attempt to match this path to provide a fully built request to the
|
||||
// access checker.
|
||||
try {
|
||||
$request->attributes->add(\Drupal::service('router')->matchRequest($request));
|
||||
}
|
||||
else {
|
||||
$router_path = $path;
|
||||
catch (ParamNotConvertedException $e) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if ($path == '<front>' || url_is_external($path)) {
|
||||
$item = array('access' => TRUE);
|
||||
}
|
||||
elseif (($collection = $route_provider->getRoutesByPattern('/' . $router_path)) && $collection->count() > 0) {
|
||||
$routes = $collection->all();
|
||||
$route_name = key($routes);
|
||||
}
|
||||
elseif ($dynamic_allowed && preg_match('/\/\%/', $path)) {
|
||||
// Path is dynamic (ie 'user/%'), so check directly against menu_router table.
|
||||
if ($item = db_query("SELECT * FROM {menu_router} where path = :path", array(':path' => $path))->fetchAssoc()) {
|
||||
$item['link_path'] = $item['path'];
|
||||
$item['link_title'] = $item['title'];
|
||||
$item['external'] = FALSE;
|
||||
$item['options'] = '';
|
||||
_menu_link_translate($item);
|
||||
$route_name = $item['route_name'];
|
||||
}
|
||||
}
|
||||
// Check the new routing system.
|
||||
if (!empty($route_name)) {
|
||||
$map = array();
|
||||
$route = \Drupal::service('router.route_provider')->getRouteByName($route_name);
|
||||
$request = RequestHelper::duplicate(\Drupal::request(), '/' . $path);
|
||||
$request->attributes->set('_system_path', $path);
|
||||
$request->attributes->set('_menu_admin', TRUE);
|
||||
|
||||
$item['access'] = menu_item_route_access($route, $path, $map, $request);
|
||||
}
|
||||
$menu_admin = FALSE;
|
||||
return !empty($item['access']);
|
||||
// Consult the accsss manager.
|
||||
$routes = $collection->all();
|
||||
$route = reset($routes);
|
||||
return \Drupal::service('access_manager')->check($route, $request, \Drupal::currentUser());
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@
|
|||
namespace Drupal\Core\EventSubscriber;
|
||||
|
||||
use Drupal\Core\Cache\Cache;
|
||||
use Drupal\Core\Lock\LockBackendInterface;
|
||||
use Drupal\Core\Routing\RouteBuilderInterface;
|
||||
use Drupal\Core\Routing\RoutingEvents;
|
||||
use Symfony\Component\EventDispatcher\Event;
|
||||
|
@ -16,7 +17,7 @@ use Symfony\Component\HttpKernel\Event\PostResponseEvent;
|
|||
use Symfony\Component\HttpKernel\KernelEvents;
|
||||
|
||||
/**
|
||||
* Rebuilds the router and menu_router if necessary.
|
||||
* Rebuilds the default menu links and runs menu-specific code if necessary.
|
||||
*/
|
||||
class RouterRebuildSubscriber implements EventSubscriberInterface {
|
||||
|
||||
|
@ -25,14 +26,22 @@ class RouterRebuildSubscriber implements EventSubscriberInterface {
|
|||
*/
|
||||
protected $routeBuilder;
|
||||
|
||||
/**
|
||||
* @var \Drupal\Core\Lock\LockBackendInterface
|
||||
*/
|
||||
protected $lock;
|
||||
|
||||
/**
|
||||
* Constructs the RouterRebuildSubscriber object.
|
||||
*
|
||||
* @param \Drupal\Core\Routing\RouteBuilderInterface $route_builder
|
||||
* The route builder.
|
||||
* @param \Drupal\Core\Lock\LockBackendInterface $lock
|
||||
* The lock backend.
|
||||
*/
|
||||
public function __construct(RouteBuilderInterface $route_builder) {
|
||||
public function __construct(RouteBuilderInterface $route_builder, LockBackendInterface $lock) {
|
||||
$this->routeBuilder = $route_builder;
|
||||
$this->lock = $lock;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,16 +55,44 @@ class RouterRebuildSubscriber implements EventSubscriberInterface {
|
|||
}
|
||||
|
||||
/**
|
||||
* Rebuilds the menu_router and deletes the local_task cache tag.
|
||||
* Rebuilds the menu links and deletes the local_task cache tag.
|
||||
*
|
||||
* @param \Symfony\Component\EventDispatcher\Event $event
|
||||
* The event object.
|
||||
*/
|
||||
public function onRouterRebuild(Event $event) {
|
||||
menu_router_rebuild();
|
||||
$this->menuLinksRebuild();
|
||||
Cache::deleteTags(array('local_task' => 1));
|
||||
}
|
||||
|
||||
/**
|
||||
* Perform menu-specific rebuilding.
|
||||
*/
|
||||
protected function menuLinksRebuild() {
|
||||
if ($this->lock->acquire(__FUNCTION__)) {
|
||||
$transaction = db_transaction();
|
||||
try {
|
||||
// Ensure the menu links are up to date.
|
||||
menu_link_rebuild_defaults();
|
||||
// Clear the menu, page and block caches.
|
||||
menu_cache_clear_all();
|
||||
_menu_clear_page_cache();
|
||||
}
|
||||
catch (\Exception $e) {
|
||||
$transaction->rollback();
|
||||
watchdog_exception('menu', $e);
|
||||
}
|
||||
|
||||
$this->lock->release(__FUNCTION__);
|
||||
}
|
||||
else {
|
||||
// Wait for another request that is already doing this work.
|
||||
// We choose to block here since otherwise the router item may not
|
||||
// be available during routing resulting in a 404.
|
||||
$this->lock->wait(__FUNCTION__);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Registers the methods in this class that should be listeners.
|
||||
*
|
||||
|
|
|
@ -70,7 +70,7 @@ class BasicAuth implements AuthenticationProviderInterface {
|
|||
*/
|
||||
public function handleException(GetResponseForExceptionEvent $event) {
|
||||
$exception = $event->getException();
|
||||
if (user_is_anonymous() && $exception instanceof AccessDeniedHttpException) {
|
||||
if ($GLOBALS['user']->isAnonymous() && $exception instanceof AccessDeniedHttpException) {
|
||||
if (!$this->applies($event->getRequest())) {
|
||||
$site_name = $this->configFactory->get('system.site')->get('name');
|
||||
global $base_url;
|
||||
|
|
|
@ -158,7 +158,7 @@ class CustomBlockTypeTest extends CustomBlockTestBase {
|
|||
foreach ($themes as $default_theme) {
|
||||
// Change the default theme.
|
||||
$theme_settings->set('default', $default_theme)->save();
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
// For each enabled theme, go to its block page and test the redirects.
|
||||
$themes = array('bartik', 'stark', 'seven');
|
||||
|
|
|
@ -865,7 +865,7 @@ class BookManager {
|
|||
* Provides menu link access control, translation, and argument handling.
|
||||
*
|
||||
* This function is similar to _menu_translate(), but it also does
|
||||
* link-specific preparation (such as always calling to_arg() functions).
|
||||
* link-specific preparation.
|
||||
*
|
||||
* @param $item
|
||||
* A menu link.
|
||||
|
|
|
@ -228,7 +228,7 @@ function contact_form_user_form_alter(&$form, &$form_state) {
|
|||
'#weight' => 5,
|
||||
);
|
||||
$account = $form_state['controller']->getEntity();
|
||||
$account_data = !user_is_anonymous() ? \Drupal::service('user.data')->get('contact', $account->id(), 'enabled') : NULL;
|
||||
$account_data = !\Drupal::currentUser()->isAnonymous() ? \Drupal::service('user.data')->get('contact', $account->id(), 'enabled') : NULL;
|
||||
$form['contact']['contact'] = array(
|
||||
'#type' => 'checkbox',
|
||||
'#title' => t('Personal contact form'),
|
||||
|
|
|
@ -181,62 +181,6 @@ function content_translation_entity_operation_alter(array &$operations, \Drupal\
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*
|
||||
* @todo Split this into route definition and menu link definition. See
|
||||
* https://drupal.org/node/1987882 and https://drupal.org/node/2047633.
|
||||
*/
|
||||
function content_translation_menu() {
|
||||
$items = array();
|
||||
|
||||
// Create tabs for all possible entity types.
|
||||
foreach (\Drupal::entityManager()->getDefinitions() as $entity_type_id => $entity_type) {
|
||||
// Provide the translation UI only for enabled types.
|
||||
if (content_translation_enabled($entity_type_id)) {
|
||||
$path = _content_translation_link_to_router_path($entity_type_id, $entity_type->getLinkTemplate('canonical'));
|
||||
$entity_position = count(explode('/', $path)) - 1;
|
||||
$keys = array_flip(array('load_arguments'));
|
||||
$translation = $entity_type->get('translation');
|
||||
$menu_info = array_intersect_key($translation['content_translation'], $keys) + array('file' => 'content_translation.pages.inc');
|
||||
$item = array();
|
||||
|
||||
// Plugin annotations cannot contain spaces, thus we need to restore them
|
||||
// from underscores.
|
||||
foreach ($menu_info as $key => $value) {
|
||||
$item[str_replace('_', ' ', $key)] = $value;
|
||||
}
|
||||
|
||||
// Add translation callback.
|
||||
// @todo Add the access callback instead of replacing it as soon as the
|
||||
// routing system supports multiple callbacks.
|
||||
$language_position = $entity_position + 3;
|
||||
$args = array($entity_position, $language_position, $language_position + 1);
|
||||
$items["$path/translations/add/%language/%language"] = array(
|
||||
'title' => 'Add',
|
||||
'route_name' => "content_translation.translation_add_$entity_type_id",
|
||||
'weight' => 1,
|
||||
);
|
||||
|
||||
// Edit translation callback.
|
||||
$args = array($entity_position, $language_position);
|
||||
$items["$path/translations/edit/%language"] = array(
|
||||
'title' => 'Edit',
|
||||
'route_name' => "content_translation.translation_edit_$entity_type_id",
|
||||
'weight' => 1,
|
||||
);
|
||||
|
||||
// Delete translation callback.
|
||||
$items["$path/translations/delete/%language"] = array(
|
||||
'title' => 'Delete',
|
||||
'route_name' => "content_translation.delete_$entity_type_id",
|
||||
) + $item;
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_alter().
|
||||
*
|
||||
|
@ -973,7 +917,7 @@ function content_translation_language_configuration_element_submit(array $form,
|
|||
if (content_translation_enabled($context['entity_type'], $context['bundle']) != $enabled) {
|
||||
content_translation_set_config($context['entity_type'], $context['bundle'], 'enabled', $enabled);
|
||||
entity_info_cache_clear();
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1041,5 +985,5 @@ function content_translation_save_settings($settings) {
|
|||
|
||||
// Ensure entity and menu router information are correctly rebuilt.
|
||||
entity_info_cache_clear();
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ abstract class ContentTranslationTestBase extends WebTestBase {
|
|||
content_translation_set_config($this->entityTypeId, $this->bundle, 'enabled', TRUE);
|
||||
drupal_static_reset();
|
||||
entity_info_cache_clear();
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -104,7 +104,7 @@ class MenuDeleteForm extends EntityConfirmFormBase {
|
|||
return;
|
||||
}
|
||||
|
||||
// Reset all the menu links defined by the system via hook_menu().
|
||||
// Reset all the menu links defined by the system via hook_menu_link_defaults().
|
||||
// @todo Convert this to an EFQ.
|
||||
$result = $this->connection->query("SELECT mlid FROM {menu_links} WHERE menu_name = :menu AND module = 'system' ORDER BY depth ASC", array(':menu' => $this->entity->id()), array('fetch' => \PDO::FETCH_ASSOC))->fetchCol();
|
||||
$menu_links = $this->storageController->loadMultiple($result);
|
||||
|
|
|
@ -235,8 +235,6 @@ class MenuFormController extends EntityFormController {
|
|||
* their form submit handler.
|
||||
*/
|
||||
protected function buildOverviewForm(array &$form, array &$form_state) {
|
||||
global $menu_admin;
|
||||
|
||||
// Ensure that menu_overview_form_submit() knows the parents of this form
|
||||
// section.
|
||||
$form['#tree'] = TRUE;
|
||||
|
@ -261,10 +259,11 @@ class MenuFormController extends EntityFormController {
|
|||
$tree = menu_tree_data($links);
|
||||
$node_links = array();
|
||||
menu_tree_collect_node_links($tree, $node_links);
|
||||
|
||||
// We indicate that a menu administrator is running the menu access check.
|
||||
$menu_admin = TRUE;
|
||||
$this->getRequest()->attributes->set('_menu_admin', TRUE);
|
||||
menu_tree_check_access($tree, $node_links);
|
||||
$menu_admin = FALSE;
|
||||
$this->getRequest()->attributes->set('_menu_admin', FALSE);
|
||||
|
||||
$form = array_merge($form, $this->buildOverviewTreeForm($tree, $delta));
|
||||
$form['#empty_text'] = t('There are no menu links yet. <a href="@link">Add link</a>.', array('@link' => url('admin/structure/menu/manage/' . $this->entity->id() .'/add')));
|
||||
|
|
|
@ -17,7 +17,6 @@ function menu_install() {
|
|||
// \Drupal\Core\Extension\ModuleHandler::install().
|
||||
// @see https://drupal.org/node/2181151
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
menu_router_rebuild();
|
||||
if (\Drupal::moduleHandler()->moduleExists('node')) {
|
||||
$node_types = array_keys(node_type_get_names());
|
||||
foreach ($node_types as $type_id) {
|
||||
|
@ -33,5 +32,5 @@ function menu_install() {
|
|||
* Implements hook_uninstall().
|
||||
*/
|
||||
function menu_uninstall() {
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
}
|
||||
|
|
|
@ -7,15 +7,9 @@
|
|||
|
||||
namespace Drupal\menu_link;
|
||||
|
||||
use Drupal\Component\Uuid\UuidInterface;
|
||||
use Drupal\Core\Entity\DatabaseStorageController;
|
||||
use Drupal\Core\Entity\EntityInterface;
|
||||
use Drupal\Core\Entity\EntityStorageException;
|
||||
use Drupal\Core\Database\Connection;
|
||||
use Drupal\Core\Entity\EntityTypeInterface;
|
||||
use Drupal\field\FieldInfo;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Cmf\Component\Routing\RouteProviderInterface;
|
||||
|
||||
/**
|
||||
* Controller class for menu links.
|
||||
|
@ -25,13 +19,6 @@ use Symfony\Cmf\Component\Routing\RouteProviderInterface;
|
|||
*/
|
||||
class MenuLinkStorageController extends DatabaseStorageController implements MenuLinkStorageControllerInterface {
|
||||
|
||||
/**
|
||||
* Contains all {menu_router} fields without weight.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
protected static $routerItemFields;
|
||||
|
||||
/**
|
||||
* Indicates whether the delete operation should re-parent children items.
|
||||
*
|
||||
|
@ -39,35 +26,6 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
*/
|
||||
protected $preventReparenting = FALSE;
|
||||
|
||||
/**
|
||||
* The route provider service.
|
||||
*
|
||||
* @var \Symfony\Cmf\Component\Routing\RouteProviderInterface
|
||||
*/
|
||||
protected $routeProvider;
|
||||
|
||||
/**
|
||||
* Overrides DatabaseStorageController::__construct().
|
||||
*
|
||||
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
|
||||
* The entity type definition.
|
||||
* @param \Drupal\Core\Database\Connection $database
|
||||
* The database connection to be used.
|
||||
* @param \Drupal\Component\Uuid\UuidInterface $uuid_service
|
||||
* The UUID Service.
|
||||
* @param \Symfony\Cmf\Component\Routing\RouteProviderInterface $route_provider
|
||||
* The route provider service.
|
||||
*/
|
||||
public function __construct(EntityTypeInterface $entity_type, Connection $database, UuidInterface $uuid_service, RouteProviderInterface $route_provider) {
|
||||
parent::__construct($entity_type, $database, $uuid_service);
|
||||
|
||||
$this->routeProvider = $route_provider;
|
||||
|
||||
if (empty(static::$routerItemFields)) {
|
||||
static::$routerItemFields = array_diff(drupal_schema_fields_sql('menu_router'), array('weight'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
|
@ -80,29 +38,6 @@ class MenuLinkStorageController extends DatabaseStorageController implements Men
|
|||
return parent::create($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static function createInstance(ContainerInterface $container, EntityTypeInterface $entity_type) {
|
||||
return new static(
|
||||
$entity_type,
|
||||
$container->get('database'),
|
||||
$container->get('uuid'),
|
||||
$container->get('router.route_provider')
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides DatabaseStorageController::buildQuery().
|
||||
*/
|
||||
protected function buildQuery($ids, $revision_id = FALSE) {
|
||||
$query = parent::buildQuery($ids, $revision_id);
|
||||
// Specify additional fields from the {menu_router} table.
|
||||
$query->leftJoin('menu_router', 'm', 'base.link_path = m.path');
|
||||
$query->fields('m', static::$routerItemFields);
|
||||
return $query;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides DatabaseStorageController::save().
|
||||
*/
|
||||
|
|
|
@ -55,7 +55,7 @@ class OptionsFieldUnitTestBase extends FieldUnitTestBase {
|
|||
*/
|
||||
public function setUp() {
|
||||
parent::setUp();
|
||||
$this->installSchema('system', array('router', 'menu_router'));
|
||||
$this->installSchema('system', array('router'));
|
||||
|
||||
$this->fieldDefinition = array(
|
||||
'name' => $this->fieldName,
|
||||
|
|
|
@ -324,7 +324,7 @@ abstract class WebTestBase extends TestBase {
|
|||
);
|
||||
$type = entity_create('node_type', $values);
|
||||
$status = $type->save();
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
$this->assertEqual($status, SAVED_NEW, String::format('Created content type %type.', array('%type' => $type->id())));
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ class MenuRouterRebuildTest extends WebTestBase {
|
|||
public function testMenuRouterRebuildContext() {
|
||||
// Enter a language context before rebuilding the menu router tables.
|
||||
\Drupal::configFactory()->setLanguage(language_load('nl'));
|
||||
menu_router_rebuild();
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
// Check that the language context was not used for building the menu item.
|
||||
$menu_items = \Drupal::entityManager()->getStorageController('menu_link')->loadByProperties(array('route_name' => 'menu_test.context'));
|
||||
|
|
|
@ -10,7 +10,7 @@ namespace Drupal\system\Tests\Menu;
|
|||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests menu router and hook_menu() functionality.
|
||||
* Tests menu router and hook_menu_link_defaults() functionality.
|
||||
*/
|
||||
class MenuRouterTest extends WebTestBase {
|
||||
|
||||
|
@ -45,7 +45,7 @@ class MenuRouterTest extends WebTestBase {
|
|||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Menu router',
|
||||
'description' => 'Tests menu router and hook_menu() functionality.',
|
||||
'description' => 'Tests menu router and hook_menu_link_defaults() functionality.',
|
||||
'group' => 'Menu',
|
||||
);
|
||||
}
|
||||
|
@ -69,7 +69,6 @@ class MenuRouterTest extends WebTestBase {
|
|||
$this->doTestMenuLinkMaintain();
|
||||
$this->doTestMenuLinkOptions();
|
||||
$this->doTestMenuItemHooks();
|
||||
$this->doTestDescriptionMenuItems();
|
||||
$this->doTestHookMenuIntegration();
|
||||
$this->doTestExoticPath();
|
||||
}
|
||||
|
@ -119,7 +118,6 @@ class MenuRouterTest extends WebTestBase {
|
|||
// Verify that the menu router item title is output as page title.
|
||||
$this->drupalGet('menu_callback_description');
|
||||
$this->assertText(t('Menu item description text'));
|
||||
$this->assertRaw(check_plain('<strong>Menu item description arguments</strong>'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -169,7 +167,7 @@ class MenuRouterTest extends WebTestBase {
|
|||
}
|
||||
|
||||
/**
|
||||
* Tests for menu_name parameter for hook_menu().
|
||||
* Tests for menu_name parameter for hook_menu_link_defaults().
|
||||
*/
|
||||
protected function doTestMenuName() {
|
||||
$admin_user = $this->drupalCreateUser(array('administer site configuration'));
|
||||
|
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Definition of Drupal\system\Tests\Menu\RebuildTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\system\Tests\Menu;
|
||||
|
||||
use Drupal\Core\Routing\RouteBuilderInterface;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
|
||||
/**
|
||||
* Tests rebuilding the router.
|
||||
*/
|
||||
class RebuildTest extends WebTestBase {
|
||||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Menu rebuild test',
|
||||
'description' => 'Test rebuilding of menu.',
|
||||
'group' => 'Menu',
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that set a router rebuild needed works.
|
||||
*/
|
||||
function testMenuRebuild() {
|
||||
// Check if 'admin' path exists.
|
||||
$admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
|
||||
$this->assertEqual($admin_exists, 'admin', "The path 'admin/' exists prior to deleting.");
|
||||
|
||||
// Delete the path item 'admin', and test that the path doesn't exist in the database.
|
||||
db_delete('menu_router')
|
||||
->condition('path', 'admin')
|
||||
->execute();
|
||||
$admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
|
||||
$this->assertFalse($admin_exists, "The path 'admin/' has been deleted and doesn't exist in the database.");
|
||||
|
||||
// Now we set the router to be rebuilt. After the rebuild 'admin' should exist.
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
|
||||
// The request should trigger the rebuild.
|
||||
$this->drupalGet('<front>');
|
||||
$admin_exists = db_query('SELECT path from {menu_router} WHERE path = :path', array(':path' => 'admin'))->fetchField();
|
||||
$this->assertEqual($admin_exists, 'admin', "The menu has been rebuilt, the path 'admin' now exists again.");
|
||||
}
|
||||
|
||||
}
|
|
@ -14,7 +14,7 @@ use Symfony\Component\Routing\Route;
|
|||
use Symfony\Component\Routing\RouteCollection;
|
||||
|
||||
/**
|
||||
* Tests the access check for menu tree using both hook_menu() and route items.
|
||||
* Tests the access check for menu tree using both menu links and route items.
|
||||
*/
|
||||
|
||||
class TreeAccessTest extends DrupalUnitTestBase {
|
||||
|
@ -43,7 +43,7 @@ class TreeAccessTest extends DrupalUnitTestBase {
|
|||
public static function getInfo() {
|
||||
return array(
|
||||
'name' => 'Menu tree access',
|
||||
'description' => 'Tests the access check for menu tree using both hook_menu() and route items.',
|
||||
'description' => 'Tests the access check for menu tree using both menu links and route items.',
|
||||
'group' => 'Menu',
|
||||
);
|
||||
}
|
||||
|
|
|
@ -32,7 +32,7 @@ class TreeOutputTest extends DrupalUnitTestBase {
|
|||
function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('router', 'menu_router'));
|
||||
$this->installSchema('system', array('router'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
|
||||
namespace Drupal\system\Tests\Routing;
|
||||
|
||||
use Drupal\Core\Routing\RequestHelper;
|
||||
use Drupal\simpletest\WebTestBase;
|
||||
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
|
||||
|
||||
|
@ -37,17 +38,6 @@ class RouterPermissionTest extends WebTestBase {
|
|||
$path = 'router_test/test7';
|
||||
$this->drupalGet($path);
|
||||
$this->assertResponse(403, "Access denied for a route where we don't have a permission");
|
||||
// An invalid path should throw an exception.
|
||||
$map = array();
|
||||
$route = \Drupal::service('router.route_provider')->getRouteByName('router_test.7');
|
||||
try {
|
||||
menu_item_route_access($route, $path . 'invalid', $map);
|
||||
$exception = FALSE;
|
||||
}
|
||||
catch (ResourceNotFoundException $e) {
|
||||
$exception = TRUE;
|
||||
}
|
||||
$this->assertTrue($exception, 'A ResourceNotFoundException was thrown while checking access for an invalid route.');
|
||||
|
||||
$this->drupalGet('router_test/test8');
|
||||
$this->assertResponse(403, 'Access denied by default if no access specified');
|
||||
|
|
|
@ -53,12 +53,10 @@ class AdminTest extends WebTestBase {
|
|||
|
||||
// Verify that all visible, top-level administration links are listed on
|
||||
// the main administration page.
|
||||
foreach (menu_get_router() as $path => $item) {
|
||||
if (strpos($path, 'admin/') === 0 && ($item['type'] & MENU_VISIBLE_IN_TREE) && $item['_number_parts'] == 2) {
|
||||
$this->assertLink($item['title']);
|
||||
$this->assertLinkByHref($path);
|
||||
$this->assertText($item['description']);
|
||||
}
|
||||
foreach ($this->getTopLevelMenuLinks() as $item) {
|
||||
$this->assertLink($item['title']);
|
||||
$this->assertLinkByHref($item['link_path']);
|
||||
$this->assertText($item['localized_options']['attributes']['title']);
|
||||
}
|
||||
|
||||
// For each administrative listing page on which the Locale module appears,
|
||||
|
@ -110,6 +108,31 @@ class AdminTest extends WebTestBase {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns all top level menu links.
|
||||
*
|
||||
* @return \Drupal\menu_link\MenuLinkInterface[]
|
||||
*/
|
||||
protected function getTopLevelMenuLinks() {
|
||||
$route_provider = \Drupal::service('router.route_provider');
|
||||
$routes = array();
|
||||
foreach ($route_provider->getAllRoutes() as $key => $value) {
|
||||
$path = $value->getPath();
|
||||
if (strpos($path, '/admin/') === 0 && count(explode('/', $path)) == 3) {
|
||||
$routes[$key] = $key;
|
||||
}
|
||||
}
|
||||
$menu_link_ids = \Drupal::entityQuery('menu_link')
|
||||
->condition('route_name', $routes)
|
||||
->execute();
|
||||
|
||||
$menu_items = \Drupal::entityManager()->getStorageController('menu_link')->loadMultiple($menu_link_ids);
|
||||
foreach ($menu_items as &$menu_item) {
|
||||
_menu_link_translate($menu_item);
|
||||
}
|
||||
return $menu_items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Test compact mode.
|
||||
*/
|
||||
|
|
|
@ -30,12 +30,6 @@ function system_theme_default() {
|
|||
->set('default', $theme)
|
||||
->save();
|
||||
|
||||
// Rebuild the menu. This duplicates the menu_router_rebuild() in
|
||||
// theme_enable(). However, modules must know the current default theme in
|
||||
// order to use this information in hook_menu() or hook_menu_alter()
|
||||
// implementations, and saving the configuration before the theme_enable()
|
||||
// could result in a race condition where the theme is default but not
|
||||
// enabled.
|
||||
\Drupal::service('router.builder')->setRebuildNeeded();
|
||||
|
||||
// The status message depends on whether an admin theme is currently in use:
|
||||
|
|
|
@ -499,94 +499,6 @@ function hook_menu_link_defaults_alter(&$links) {
|
|||
$links['user.logout']['link_title'] = t('Logout');
|
||||
}
|
||||
|
||||
/**
|
||||
* Define links for menus.
|
||||
*
|
||||
* @section sec_menu_link Creating Menu Items
|
||||
* Menu item example of type MENU_NORMAL_ITEM:
|
||||
* @code
|
||||
* // Make "Foo settings" appear on the admin Config page
|
||||
* $items['admin/config/system/foo'] = array(
|
||||
* 'title' => 'Foo settings',
|
||||
* 'type' => MENU_NORMAL_ITEM,
|
||||
* 'route_name' => 'foo.settings'
|
||||
* );
|
||||
* @endcode
|
||||
*
|
||||
* @todo The section that used to be here about path argument substitution has
|
||||
* been removed, but is still referred to in the return section. It needs to
|
||||
* be added back in, or a corrected version of it.
|
||||
*
|
||||
* @return
|
||||
* An array of menu items. Each menu item has a key corresponding to the
|
||||
* Drupal path being registered. The corresponding array value is an
|
||||
* associative array that may contain the following key-value pairs:
|
||||
* - "title": Required. The untranslated title of the menu item.
|
||||
* - "title callback": Function to generate the title; defaults to t().
|
||||
* If you require only the raw string to be output, set this to FALSE.
|
||||
* - "title arguments": Arguments to send to t() or your custom callback,
|
||||
* with path component substitution as described above.
|
||||
* - "description": The untranslated description of the menu item.
|
||||
* - description callback: Function to generate the description; defaults to
|
||||
* t(). If you require only the raw string to be output, set this to FALSE.
|
||||
* - description arguments: Arguments to send to t() or your custom callback,
|
||||
* with path component substitution as described above.
|
||||
* - "weight": An integer that determines the relative position of items in
|
||||
* the menu; higher-weighted items sink. Defaults to 0. Menu items with the
|
||||
* same weight are ordered alphabetically.
|
||||
* - "menu_name": Optional. Set this to a custom menu if you don't want your
|
||||
* item to be placed in the default Tools menu.
|
||||
* - "expanded": Optional. If set to TRUE, and if a menu link is provided for
|
||||
* this menu item (as a result of other properties), then the menu link is
|
||||
* always expanded, equivalent to its 'always expanded' checkbox being set
|
||||
* in the UI.
|
||||
* - "position": Position of the block ('left' or 'right') on the system
|
||||
* administration page for this item.
|
||||
* - "type": A bitmask of flags describing properties of the menu item.
|
||||
* Many shortcut bitmasks are provided as constants in menu.inc:
|
||||
* - MENU_NORMAL_ITEM: Normal menu items show up in the menu tree and can be
|
||||
* moved/hidden by the administrator.
|
||||
* - MENU_SUGGESTED_ITEM: Modules may "suggest" menu items that the
|
||||
* administrator may enable.
|
||||
* If the "type" element is omitted, MENU_NORMAL_ITEM is assumed.
|
||||
* - "options": An array of options to be passed to l() when generating a link
|
||||
* from this menu item.
|
||||
*
|
||||
* For a detailed usage example, see page_example.module.
|
||||
* For comprehensive documentation on the menu system, see
|
||||
* http://drupal.org/node/102338.
|
||||
*
|
||||
* @see menu
|
||||
*/
|
||||
function hook_menu() {
|
||||
$items['example'] = array(
|
||||
'title' => 'Example Page',
|
||||
'route_name' => 'example.page',
|
||||
);
|
||||
$items['example/feed'] = array(
|
||||
'title' => 'Example RSS feed',
|
||||
'route_name' => 'example.feed',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter the data being saved to the {menu_router} table after hook_menu is invoked.
|
||||
*
|
||||
* This hook is invoked by menu_router_build(). The menu definitions are passed
|
||||
* in by reference. Each element of the $items array is one item returned
|
||||
* by a module from hook_menu. Additional items may be added, or existing items
|
||||
* altered.
|
||||
*
|
||||
* @param $items
|
||||
* Associative array of menu router definitions returned from hook_menu().
|
||||
*/
|
||||
function hook_menu_alter(&$items) {
|
||||
// Example - disable the page at node/add
|
||||
$items['node/add']['access callback'] = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Alter tabs and actions displayed on the page before they are rendered.
|
||||
*
|
||||
|
@ -1524,11 +1436,6 @@ function hook_cache_flush() {
|
|||
* system is known to return current information, so your module can safely rely
|
||||
* on all available data to rebuild its own.
|
||||
*
|
||||
* The menu router is the only exception regarding rebuilt data; it is only
|
||||
* rebuilt after all hook_rebuild() implementations have been invoked. That
|
||||
* ensures that hook_menu() implementations and the final router rebuild can
|
||||
* rely on all data being returned by all modules.
|
||||
*
|
||||
* @see hook_cache_flush()
|
||||
* @see drupal_flush_all_caches()
|
||||
*/
|
||||
|
|
|
@ -729,161 +729,6 @@ function system_schema() {
|
|||
),
|
||||
);
|
||||
|
||||
$schema['menu_router'] = array(
|
||||
'description' => 'Maps paths to various callbacks (access, page and title)',
|
||||
'fields' => array(
|
||||
'path' => array(
|
||||
'description' => 'Primary Key: the Drupal path this entry describes',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'load_functions' => array(
|
||||
'description' => 'A serialized array of function names (like node_load) to be called to load an object corresponding to a part of the current path.',
|
||||
'type' => 'blob',
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'to_arg_functions' => array(
|
||||
'description' => 'A serialized array of function names (like user_uid_optional_to_arg) to be called to replace a part of the router path with another string.',
|
||||
'type' => 'blob',
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'access_callback' => array(
|
||||
'description' => 'The callback which determines the access to this router path. Defaults to user_access.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'access_arguments' => array(
|
||||
'description' => 'A serialized array of arguments for the access callback.',
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'page_callback' => array(
|
||||
'description' => 'The name of the function that renders the page.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'page_arguments' => array(
|
||||
'description' => 'A serialized array of arguments for the page callback.',
|
||||
'type' => 'blob',
|
||||
'not null' => FALSE,
|
||||
),
|
||||
'fit' => array(
|
||||
'description' => 'A numeric representation of how specific the path is.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'number_parts' => array(
|
||||
'description' => 'Number of parts in this router path.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
'size' => 'small',
|
||||
),
|
||||
'context' => array(
|
||||
'description' => 'Only for local tasks (tabs) - the context of a local task to control its placement.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'tab_parent' => array(
|
||||
'description' => 'Only for local tasks (tabs) - the router path of the parent page (which may also be a local task).',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'tab_root' => array(
|
||||
'description' => 'Router path of the closest non-tab parent page. For pages that are not local tasks, this will be the same as the path.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'title' => array(
|
||||
'description' => 'The title for the current page, or the title for the tab if this is a local task.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'title_callback' => array(
|
||||
'description' => 'A function which will alter the title. Defaults to t()',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'title_arguments' => array(
|
||||
'description' => 'A serialized array of arguments for the title callback. If empty, the title will be used as the sole argument for the title callback.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'type' => array(
|
||||
'description' => 'Numeric representation of the type of the menu item, like MENU_LOCAL_TASK.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'description' => array(
|
||||
'description' => 'A description of this item.',
|
||||
'type' => 'text',
|
||||
'not null' => TRUE,
|
||||
),
|
||||
'description_callback' => array(
|
||||
'description' => 'A function which will alter the description. Defaults to t().',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'description_arguments' => array(
|
||||
'description' => 'A serialized array of arguments for the description callback. If empty, the description will be used as the sole argument for the description callback.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'position' => array(
|
||||
'description' => 'The position of the block (left or right) on the system administration page for this item.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
'not null' => TRUE,
|
||||
'default' => '',
|
||||
),
|
||||
'weight' => array(
|
||||
'description' => 'Weight of the element. Lighter weights are higher up, heavier weights go down.',
|
||||
'type' => 'int',
|
||||
'not null' => TRUE,
|
||||
'default' => 0,
|
||||
),
|
||||
'include_file' => array(
|
||||
'description' => 'The file to include for this element, usually the page callback function lives in this file.',
|
||||
'type' => 'text',
|
||||
'size' => 'medium',
|
||||
),
|
||||
'route_name' => array(
|
||||
'description' => 'The machine name of a defined Symfony Route this menu item represents.',
|
||||
'type' => 'varchar',
|
||||
'length' => 255,
|
||||
),
|
||||
),
|
||||
'indexes' => array(
|
||||
'fit' => array('fit'),
|
||||
'tab_parent' => array(array('tab_parent', 64), 'weight', 'title'),
|
||||
'tab_root_weight_title' => array(array('tab_root', 64), 'weight', 'title'),
|
||||
),
|
||||
'primary key' => array('path'),
|
||||
);
|
||||
|
||||
$schema['queue'] = array(
|
||||
'description' => 'Stores items in queues.',
|
||||
'fields' => array(
|
||||
|
|
|
@ -626,206 +626,6 @@ function system_element_info() {
|
|||
return $types;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function system_menu() {
|
||||
$items['admin'] = array(
|
||||
'title' => 'Administration',
|
||||
'route_name' => 'system.admin',
|
||||
'weight' => 9,
|
||||
'menu_name' => 'admin',
|
||||
);
|
||||
|
||||
// Menu items that are basically just menu blocks.
|
||||
$items['admin/structure'] = array(
|
||||
'title' => 'Structure',
|
||||
'description' => 'Administer blocks, content types, menus, etc.',
|
||||
'position' => 'right',
|
||||
'weight' => -8,
|
||||
'route_name' => 'system.admin_structure',
|
||||
);
|
||||
// Appearance.
|
||||
$items['admin/appearance'] = array(
|
||||
'title' => 'Appearance',
|
||||
'description' => 'Select and configure your themes.',
|
||||
'route_name' => 'system.themes_page',
|
||||
'position' => 'left',
|
||||
'weight' => -6,
|
||||
);
|
||||
|
||||
// Modules.
|
||||
$items['admin/modules'] = array(
|
||||
'title' => 'Extend',
|
||||
'description' => 'Add and enable modules to extend site functionality.',
|
||||
'route_name' => 'system.modules_list',
|
||||
'weight' => -2,
|
||||
);
|
||||
|
||||
// Configuration.
|
||||
$items['admin/config'] = array(
|
||||
'title' => 'Configuration',
|
||||
'description' => 'Administer settings.',
|
||||
'route_name' => 'system.admin_config',
|
||||
);
|
||||
|
||||
// Media settings.
|
||||
$items['admin/config/media'] = array(
|
||||
'title' => 'Media',
|
||||
'description' => 'Media tools.',
|
||||
'position' => 'left',
|
||||
'weight' => -10,
|
||||
'route_name' => 'system.admin_config_media',
|
||||
);
|
||||
$items['admin/config/media/file-system'] = array(
|
||||
'title' => 'File system',
|
||||
'description' => 'Tell Drupal where to store uploaded files and how they are accessed.',
|
||||
'route_name' => 'system.file_system_settings',
|
||||
'weight' => -10,
|
||||
);
|
||||
$items['admin/config/media/image-toolkit'] = array(
|
||||
'title' => 'Image toolkit',
|
||||
'description' => 'Choose which image toolkit to use if you have installed optional toolkits.',
|
||||
'route_name' => 'system.image_toolkit_settings',
|
||||
'weight' => 20,
|
||||
);
|
||||
|
||||
// Service settings.
|
||||
$items['admin/config/services'] = array(
|
||||
'title' => 'Web services',
|
||||
'description' => 'Tools related to web services.',
|
||||
'position' => 'right',
|
||||
'weight' => 0,
|
||||
'route_name' => 'system.admin_config_services',
|
||||
);
|
||||
$items['admin/config/services/rss-publishing'] = array(
|
||||
'title' => 'RSS publishing',
|
||||
'description' => 'Configure the site description, the number of items per feed and whether feeds should be titles/teasers/full-text.',
|
||||
'route_name' => 'system.rss_feeds_settings',
|
||||
);
|
||||
|
||||
// Development settings.
|
||||
$items['admin/config/development'] = array(
|
||||
'title' => 'Development',
|
||||
'description' => 'Development tools.',
|
||||
'position' => 'right',
|
||||
'weight' => -10,
|
||||
'route_name' => 'system.admin_config_development',
|
||||
);
|
||||
$items['admin/config/development/maintenance'] = array(
|
||||
'title' => 'Maintenance mode',
|
||||
'description' => 'Take the site offline for maintenance or bring it back online.',
|
||||
'route_name' => 'system.site_maintenance_mode',
|
||||
'weight' => -10,
|
||||
);
|
||||
$items['admin/config/development/performance'] = array(
|
||||
'title' => 'Performance',
|
||||
'description' => 'Enable or disable page caching for anonymous users and set CSS and JS bandwidth optimization options.',
|
||||
'route_name' => 'system.performance_settings',
|
||||
'weight' => -20,
|
||||
);
|
||||
$items['admin/config/development/logging'] = array(
|
||||
'title' => 'Logging and errors',
|
||||
'description' => "Settings for logging and alerts modules. Various modules can route Drupal's system events to different destinations, such as syslog, database, email, etc.",
|
||||
'route_name' => 'system.logging_settings',
|
||||
'weight' => -15,
|
||||
);
|
||||
|
||||
// Regional and date settings.
|
||||
$items['admin/config/regional'] = array(
|
||||
'title' => 'Regional and language',
|
||||
'description' => 'Regional settings, localization and translation.',
|
||||
'position' => 'left',
|
||||
'weight' => -5,
|
||||
'route_name' => 'system.admin_config_regional',
|
||||
);
|
||||
$items['admin/config/regional/settings'] = array(
|
||||
'title' => 'Regional settings',
|
||||
'description' => "Settings for the site's default time zone and country.",
|
||||
'route_name' => 'system.regional_settings',
|
||||
'weight' => -20,
|
||||
);
|
||||
$items['admin/config/regional/date-time'] = array(
|
||||
'title' => 'Date and time formats',
|
||||
'description' => 'Configure display format strings for date and time.',
|
||||
'route_name' => 'system.date_format_list',
|
||||
'weight' => -5,
|
||||
);
|
||||
$items['admin/config/regional/date-time/formats/manage/%'] = array(
|
||||
'title' => 'Edit date format',
|
||||
'description' => 'Allow users to edit a configured date format.',
|
||||
'route_name' => 'system.date_format_edit',
|
||||
);
|
||||
|
||||
// Search settings.
|
||||
$items['admin/config/search'] = array(
|
||||
'title' => 'Search and metadata',
|
||||
'description' => 'Local site search, metadata and SEO.',
|
||||
'position' => 'left',
|
||||
'weight' => -10,
|
||||
'route_name' => 'system.admin_config_search',
|
||||
);
|
||||
|
||||
// System settings.
|
||||
$items['admin/config/system'] = array(
|
||||
'title' => 'System',
|
||||
'description' => 'General system related configuration.',
|
||||
'position' => 'right',
|
||||
'weight' => -20,
|
||||
'route_name' => 'system.admin_config_system',
|
||||
);
|
||||
$items['admin/config/system/site-information'] = array(
|
||||
'title' => 'Site information',
|
||||
'description' => 'Change site name, e-mail address, slogan, default front page and error pages.',
|
||||
'route_name' => 'system.site_information_settings',
|
||||
'weight' => -20,
|
||||
);
|
||||
$items['admin/config/system/cron'] = array(
|
||||
'title' => 'Cron',
|
||||
'description' => 'Manage automatic site maintenance tasks.',
|
||||
'route_name' => 'system.cron_settings',
|
||||
'weight' => 20,
|
||||
);
|
||||
// Additional categories
|
||||
$items['admin/config/user-interface'] = array(
|
||||
'title' => 'User interface',
|
||||
'description' => 'Tools that enhance the user interface.',
|
||||
'position' => 'right',
|
||||
'route_name' => 'system.admin_config_ui',
|
||||
'weight' => -15,
|
||||
);
|
||||
$items['admin/config/workflow'] = array(
|
||||
'title' => 'Workflow',
|
||||
'description' => 'Content workflow, editorial workflow tools.',
|
||||
'position' => 'right',
|
||||
'weight' => 5,
|
||||
'route_name' => 'system.admin_config_workflow',
|
||||
);
|
||||
$items['admin/config/content'] = array(
|
||||
'title' => 'Content authoring',
|
||||
'description' => 'Settings related to formatting and authoring content.',
|
||||
'position' => 'left',
|
||||
'weight' => -15,
|
||||
'route_name' => 'system.admin_config_content',
|
||||
);
|
||||
|
||||
// Reports.
|
||||
$items['admin/reports'] = array(
|
||||
'title' => 'Reports',
|
||||
'description' => 'View reports, updates, and errors.',
|
||||
'route_name' => 'system.admin_reports',
|
||||
'weight' => 5,
|
||||
'position' => 'left',
|
||||
);
|
||||
$items['admin/reports/status'] = array(
|
||||
'title' => 'Status report',
|
||||
'description' => "Get a status report about your site's operation and any detected problems.",
|
||||
'route_name' => 'system.status',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_defaults().
|
||||
*/
|
||||
|
@ -849,12 +649,14 @@ function system_menu_link_defaults() {
|
|||
$items['system.admin.appearance'] = array(
|
||||
'route_name' => 'system.themes_page',
|
||||
'link_title' => 'Appearance',
|
||||
'description' => 'Select and configure your themes.',
|
||||
'parent' => 'system.admin',
|
||||
'weight' => -6,
|
||||
);
|
||||
// Modules.
|
||||
$items['system.admin.modules'] = array(
|
||||
'link_title' => 'Extend',
|
||||
'description' => 'Add and enable modules to extend site functionality.',
|
||||
'parent' => 'system.admin',
|
||||
'route_name' => 'system.modules_list',
|
||||
'weight' => -2,
|
||||
|
|
|
@ -5,20 +5,6 @@
|
|||
* Helper module for the Batch API tests.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function batch_test_menu() {
|
||||
$items = array();
|
||||
|
||||
$items['batch-test'] = array(
|
||||
'title' => 'Batch test',
|
||||
'route_name' => 'batch_test.test_form',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Form constructor for a batch selection form.
|
||||
*
|
||||
|
|
|
@ -239,30 +239,6 @@ function entity_test_permission() {
|
|||
return $permissions;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function entity_test_menu() {
|
||||
$items = array();
|
||||
$types = entity_test_entity_types();
|
||||
|
||||
foreach($types as $entity_type) {
|
||||
$items[$entity_type . '/add'] = array(
|
||||
'title' => 'Add an @type',
|
||||
'title arguments' => array('@type' => $entity_type),
|
||||
'route_name' => "entity_test.add_$entity_type",
|
||||
);
|
||||
|
||||
$items[$entity_type . '/manage/%' . $entity_type] = array(
|
||||
'title' => 'Edit @type',
|
||||
'title arguments' => array('@type' => $entity_type),
|
||||
'route_name' => "entity_test.edit_$entity_type",
|
||||
);
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_form_BASE_FORM_ID_alter().
|
||||
*/
|
||||
|
|
|
@ -7,147 +7,6 @@
|
|||
|
||||
use Drupal\menu_link\Entity\MenuLink;
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*/
|
||||
function menu_test_menu() {
|
||||
// The name of the menu changes during the course of the test. Using a GET.
|
||||
$items['menu_name_test'] = array(
|
||||
'title' => 'Test menu_name router item',
|
||||
'route_name' => 'menu_test.menu_name_test',
|
||||
'menu_name' => menu_test_menu_name(),
|
||||
);
|
||||
// This item uses SystemController::systemAdminMenuBlockPage() to list child
|
||||
// items.
|
||||
$items['menu_callback_description'] = array(
|
||||
'title' => 'Menu item title',
|
||||
'description' => 'Menu item description parent',
|
||||
'route_name' => 'menu_test.callback_description',
|
||||
);
|
||||
// This item tests the description key.
|
||||
$items['menu_callback_description/description-plain'] = array(
|
||||
'title' => 'Menu item with a regular description',
|
||||
'description' => 'Menu item description text',
|
||||
'route_name' => 'menu_test.callback_description_plain',
|
||||
);
|
||||
// This item tests using a description callback.
|
||||
$items['menu_callback_description/description-callback'] = array(
|
||||
'title' => 'Menu item with a description set with a callback',
|
||||
'description callback' => 'check_plain',
|
||||
'description arguments' => array('<strong>Menu item description arguments</strong>'),
|
||||
'route_name' => 'menu_test.callback_description_callback',
|
||||
);
|
||||
// Use FALSE as 'title callback' to bypass t().
|
||||
$items['menu_no_title_callback'] = array(
|
||||
'title' => 'A title with @placeholder',
|
||||
'title callback' => FALSE,
|
||||
'title arguments' => array('@placeholder' => 'some other text'),
|
||||
'route_name' => 'menu_test.menu_no_title_callback',
|
||||
);
|
||||
|
||||
// Hidden link for menu_link_maintain tests
|
||||
$items['menu_test_maintain/%'] = array(
|
||||
'title' => 'Menu maintain test',
|
||||
'route_name' => 'menu_test.menu_test_maintain',
|
||||
);
|
||||
// Hierarchical tests.
|
||||
$items['menu-test/hierarchy/parent'] = array(
|
||||
'title' => 'Parent menu router',
|
||||
'route_name' => 'menu_test.hierarchy_parent',
|
||||
);
|
||||
$items['menu-test/hierarchy/parent/child'] = array(
|
||||
'title' => 'Child menu router',
|
||||
'route_name' => 'menu_test.hierarchy_parent_child',
|
||||
);
|
||||
$items['menu-test/hierarchy/parent/child2/child'] = array(
|
||||
'title' => 'Unattached subchild router',
|
||||
'route_name' => 'menu_test.hierarchy_parent_child2',
|
||||
);
|
||||
// Theme callback tests.
|
||||
$items['menu-test/theme-callback/%/inheritance'] = array(
|
||||
'title' => 'Page that tests theme negotiation inheritance.',
|
||||
'route_name' => 'menu_test.theme_callback_inheritance',
|
||||
);
|
||||
$items['menu-test/no-theme-callback'] = array(
|
||||
'title' => 'Page that displays different themes without using a theme negotiation.',
|
||||
'route_name' => 'menu_test.no_theme_callback',
|
||||
);
|
||||
// Path containing "exotic" characters.
|
||||
$path = "menu-test/ -._~!$'\"()*@[]?&+%#,;=:" . // "Special" ASCII characters.
|
||||
"%23%25%26%2B%2F%3F" . // Characters that look like a percent-escaped string.
|
||||
"éøïвβ中國書۞"; // Characters from various non-ASCII alphabets.
|
||||
$items[$path] = array(
|
||||
'title' => '"Exotic" path',
|
||||
'route_name' => 'menu_test.exotic_path',
|
||||
);
|
||||
|
||||
// Hidden tests; base parents.
|
||||
// Same structure as in Menu and Block modules. Since those structures can
|
||||
// change, we need to simulate our own in here.
|
||||
$items['menu-test'] = array(
|
||||
'title' => 'Menu test root',
|
||||
'route_name' => 'menu_test.menu_test',
|
||||
);
|
||||
|
||||
// Menu trail tests.
|
||||
// @see MenuTrailTestCase
|
||||
$items['menu-test/menu-trail'] = array(
|
||||
'title' => 'Menu trail - Case 1',
|
||||
'route_name' => 'menu_test.menu_trail',
|
||||
);
|
||||
$items['admin/config/development/menu-trail'] = array(
|
||||
'title' => 'Menu trail - Case 2',
|
||||
'description' => 'Tests menu_tree_set_path()',
|
||||
'route_name' => 'menu_test.menu_trail_admin',
|
||||
);
|
||||
$items['menu-test/custom-403-page'] = array(
|
||||
'title' => 'Custom 403 page',
|
||||
'route_name' => 'menu_test.custom_403',
|
||||
);
|
||||
$items['menu-test/custom-404-page'] = array(
|
||||
'title' => 'Custom 404 page',
|
||||
'route_name' => 'menu_test.custom_404',
|
||||
);
|
||||
|
||||
// Test the access key.
|
||||
$items['menu-title-test/case1'] = array(
|
||||
'title' => 'Example title - Case 1',
|
||||
'route_name' => 'menu_test.title_test_case1',
|
||||
);
|
||||
$items['menu-title-test/case2'] = array(
|
||||
'title' => 'Example title',
|
||||
'title callback' => 'menu_test_title_callback',
|
||||
'route_name' => 'menu_test.title_test_case2',
|
||||
);
|
||||
$items['menu-title-test/case3'] = array(
|
||||
// Title gets completely ignored. Good thing, too.
|
||||
'title' => 'Bike sheds full of blue smurfs WRONG',
|
||||
'route_name' => 'menu_test.title_test_case3',
|
||||
);
|
||||
|
||||
$items['menu-test-local-action'] = array(
|
||||
'title' => 'Local action parent',
|
||||
'route_name' => 'menu_test.local_action1',
|
||||
);
|
||||
|
||||
$items['menu-local-task-test/tasks'] = array(
|
||||
'title' => 'Local tasks',
|
||||
'route_name' => 'menu_test.local_task_test_tasks',
|
||||
);
|
||||
$items['menu-test/optional'] = array(
|
||||
'title' => 'Test optional placeholder',
|
||||
'route_name' => 'menu_test.optional_placeholder',
|
||||
'type' => MENU_LOCAL_TASK,
|
||||
);
|
||||
|
||||
$items['menu-test/context'] = array(
|
||||
'title' => \Drupal::config('menu_test.menu_item')->get('title'),
|
||||
'route_name' => 'menu_test.context',
|
||||
);
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_defaults().
|
||||
*/
|
||||
|
@ -172,12 +31,6 @@ function menu_test_menu_link_defaults() {
|
|||
'route_name' => 'menu_test.callback_description_plain',
|
||||
'parent' => 'menu_test.menu_callback_description',
|
||||
);
|
||||
// This item tests using a description callback.
|
||||
$items['menu_callback_description.description-callback'] = array(
|
||||
'link_title' => 'Menu item with a description set with a callback',
|
||||
'route_name' => 'menu_test.callback_description_callback',
|
||||
'parent' => 'menu_test.menu_callback_description',
|
||||
);
|
||||
|
||||
$items['menu_test.menu_no_title_callback'] = array(
|
||||
'link_title' => 'A title with @placeholder',
|
||||
|
@ -337,36 +190,6 @@ function menu_test_menu_local_tasks_alter(&$data, $route_name) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Argument callback: Loads an argument using a function for hook_menu().
|
||||
*
|
||||
* @param string $arg1
|
||||
* A parameter passed in via the URL.
|
||||
*
|
||||
* @return false
|
||||
* Always return NULL.
|
||||
*
|
||||
* @see menu_test_menu();
|
||||
*/
|
||||
function menu_test_argument_load($arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Argument callback: Loads an argument using a function for hook_menu().
|
||||
*
|
||||
* @param string $arg1
|
||||
* A parameter passed in via the URL.
|
||||
*
|
||||
* @return false
|
||||
* Always return NULL.
|
||||
*
|
||||
* @see menu_test_menu();
|
||||
*/
|
||||
function menu_test_other_argument_load($arg1) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/**
|
||||
* Page callback: Provides a dummy function which can be used as a placeholder.
|
||||
*
|
||||
|
|
|
@ -36,14 +36,6 @@ menu_test.callback_description_plain:
|
|||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
menu_test.callback_description_callback:
|
||||
path: '/menu_callback_description/description-callback'
|
||||
defaults:
|
||||
_title: 'Menu item with a description set with a callback'
|
||||
_content: '\Drupal\menu_test\Controller\MenuTestController::menuTestCallback'
|
||||
requirements:
|
||||
_access: 'TRUE'
|
||||
|
||||
menu_test.menu_no_title_callback:
|
||||
path: '/menu_no_title_callback'
|
||||
defaults:
|
||||
|
|
|
@ -21,6 +21,6 @@ class RegisterAccessCheck implements AccessInterface {
|
|||
* Implements AccessCheckInterface::access().
|
||||
*/
|
||||
public function access(Route $route, Request $request, AccountInterface $account) {
|
||||
return ($account->isAnonymous() && (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY)) ? static::ALLOW : static::DENY;
|
||||
return ($request->attributes->get('_menu_admin') || $account->isAnonymous()) && (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY) ? static::ALLOW : static::DENY;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ class MaintenanceModeSubscriber implements EventSubscriberInterface {
|
|||
return;
|
||||
}
|
||||
|
||||
if (user_is_anonymous()) {
|
||||
if ($user->isAnonymous()) {
|
||||
switch ($path) {
|
||||
case 'user':
|
||||
// Forward anonymous user to login page.
|
||||
|
|
|
@ -4,18 +4,3 @@
|
|||
* @file
|
||||
* Dummy module implementing a form to test user password validation
|
||||
*/
|
||||
|
||||
/**
|
||||
* Implements hook_menu().
|
||||
*
|
||||
* Sets up a form that allows a user to validate password.
|
||||
*/
|
||||
function user_form_test_menu() {
|
||||
$items = array();
|
||||
$items['user_form_test_current_password/%user'] = array(
|
||||
'title' => 'User form test for current password validation',
|
||||
'route_name' => 'user_form_test.current_password',
|
||||
'type' => MENU_SUGGESTED_ITEM,
|
||||
);
|
||||
return $items;
|
||||
}
|
||||
|
|
|
@ -685,40 +685,6 @@ function theme_username($variables) {
|
|||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the current user is anonymous.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the user is anonymous, FALSE if the user is authenticated.
|
||||
*/
|
||||
function user_is_anonymous() {
|
||||
// Menu administrators can see items for anonymous when administering.
|
||||
return $GLOBALS['user']->isAnonymous() || !empty($GLOBALS['menu_admin']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the current user is logged in.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the user is logged in, FALSE if the user is anonymous.
|
||||
*
|
||||
* @deprecated in Drupal 8.x-dev, will be removed before Drupal 8.0.
|
||||
* Use \Drupal\Core\Session\UserSession::isAuthenticated().
|
||||
*/
|
||||
function user_is_logged_in() {
|
||||
return $GLOBALS['user']->isAuthenticated();
|
||||
}
|
||||
|
||||
/**
|
||||
* Determines if the current user has access to the user registration page.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if the user is not already logged in and can register for an account.
|
||||
*/
|
||||
function user_register_access() {
|
||||
return user_is_anonymous() && (\Drupal::config('user.settings')->get('register') != USER_REGISTER_ADMINISTRATORS_ONLY);
|
||||
}
|
||||
|
||||
/**
|
||||
* Implements hook_menu_link_defaults().
|
||||
*/
|
||||
|
@ -816,81 +782,6 @@ function user_admin_paths() {
|
|||
return $paths;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns $arg or the user ID of the current user if $arg is '%' or empty.
|
||||
*
|
||||
* Deprecated. Use %user_uid_optional instead.
|
||||
*
|
||||
* @todo D8: Remove.
|
||||
*/
|
||||
function user_uid_only_optional_to_arg($arg) {
|
||||
return user_uid_optional_to_arg($arg);
|
||||
}
|
||||
|
||||
/**
|
||||
* Load either a specified or the current user account.
|
||||
*
|
||||
* @param $uid
|
||||
* An optional user ID of the user to load. If not provided, the current
|
||||
* user's ID will be used.
|
||||
* @return
|
||||
* A fully-loaded $user object upon successful user load, NULL if user
|
||||
* cannot be loaded.
|
||||
*
|
||||
* @see user_load()
|
||||
* @todo rethink the naming of this in Drupal 8.
|
||||
*/
|
||||
function user_uid_optional_load($uid = NULL) {
|
||||
if (!isset($uid)) {
|
||||
$uid = $GLOBALS['user']->id();
|
||||
}
|
||||
return user_load($uid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns $arg or the user ID of the current user if $arg is '%' or empty.
|
||||
*
|
||||
* @todo rethink the naming of this in Drupal 8.
|
||||
*/
|
||||
function user_uid_optional_to_arg($arg) {
|
||||
// Give back the current user uid when called from eg. tracker, aka.
|
||||
// with an empty arg. Also use the current user uid when called from
|
||||
// the menu with a % for the current account link.
|
||||
return empty($arg) || $arg == '%' ? $GLOBALS['user']->id() : $arg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu item title callback for the 'user' path.
|
||||
*
|
||||
* Anonymous users should see a title based on the requested page, but
|
||||
* authenticated users are expected to see "My account".
|
||||
*/
|
||||
function user_menu_title() {
|
||||
if ($GLOBALS['user']->isAnonymous()) {
|
||||
switch (current_path()) {
|
||||
case 'user' :
|
||||
case 'user/login' :
|
||||
return t('Log in');
|
||||
case 'user/register' :
|
||||
return t('Create new account');
|
||||
case 'user/password' :
|
||||
return t('Request new password');
|
||||
default :
|
||||
return t('User account');
|
||||
}
|
||||
}
|
||||
else {
|
||||
return t('My account');
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Menu item title callback - use the user name.
|
||||
*/
|
||||
function user_page_title(UserInterface $account = NULL) {
|
||||
return $account ? $account->getUsername() : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* Try to validate the user's login credentials locally.
|
||||
*
|
||||
|
|
|
@ -327,121 +327,6 @@ abstract class PathPluginBase extends DisplayPluginBase implements DisplayRouter
|
|||
return $links;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::executeHookMenu().
|
||||
*/
|
||||
public function executeHookMenu($callbacks) {
|
||||
$items = array();
|
||||
// Replace % with the link to our standard views argument loader
|
||||
// views_arg_load -- which lives in views.module.
|
||||
|
||||
$bits = explode('/', $this->getOption('path'));
|
||||
$page_arguments = array($this->view->storage->id(), $this->display['id']);
|
||||
$this->view->initHandlers();
|
||||
$view_arguments = $this->view->argument;
|
||||
|
||||
$path = implode('/', $bits);
|
||||
|
||||
$view_route_names = $this->state->get('views.view_route_names') ?: array();
|
||||
|
||||
if ($path) {
|
||||
// Some views might override existing paths, so we have to set the route
|
||||
// name based upon the altering.
|
||||
$view_id_display = "{$this->view->storage->id()}.{$this->display['id']}";
|
||||
$items[$path] = array(
|
||||
'route_name' => isset($view_route_names[$view_id_display]) ? $view_route_names[$view_id_display] : "view.$view_id_display",
|
||||
// Identify URL embedded arguments and correlate them to a handler.
|
||||
'load arguments' => array($this->view->storage->id(), $this->display['id'], '%index'),
|
||||
);
|
||||
$menu = $this->getOption('menu');
|
||||
if (empty($menu)) {
|
||||
$menu = array('type' => 'none');
|
||||
}
|
||||
// Set the title and description if we have one.
|
||||
if ($menu['type'] != 'none') {
|
||||
$items[$path]['title'] = $menu['title'];
|
||||
$items[$path]['description'] = $menu['description'];
|
||||
}
|
||||
|
||||
if (isset($menu['weight'])) {
|
||||
$items[$path]['weight'] = intval($menu['weight']);
|
||||
}
|
||||
|
||||
switch ($menu['type']) {
|
||||
case 'none':
|
||||
default:
|
||||
$items[$path]['type'] = MENU_CALLBACK;
|
||||
break;
|
||||
case 'normal':
|
||||
$items[$path]['type'] = MENU_NORMAL_ITEM;
|
||||
// Insert item into the proper menu.
|
||||
$items[$path]['menu_name'] = $menu['name'];
|
||||
break;
|
||||
case 'tab':
|
||||
$items[$path]['type'] = MENU_CALLBACK;
|
||||
break;
|
||||
case 'default tab':
|
||||
$items[$path]['type'] = MENU_CALLBACK;
|
||||
break;
|
||||
}
|
||||
|
||||
// Add context for contextual links.
|
||||
if (in_array($menu['type'], array('tab', 'default tab'))) {
|
||||
// @todo Remove once contextual links are ported to a new plugin based
|
||||
// system.
|
||||
if (!empty($menu['context'])) {
|
||||
$items[$path]['context'] = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// If this is a 'default' tab, check to see if we have to create the
|
||||
// parent menu item.
|
||||
if ($this->isDefaultTabPath()) {
|
||||
$tab_options = $this->getOption('tab_options');
|
||||
|
||||
$bits = explode('/', $path);
|
||||
// Remove the last piece.
|
||||
$bit = array_pop($bits);
|
||||
|
||||
// Default tabs are handled by the local task plugins.
|
||||
if ($tab_options['type'] == 'tab') {
|
||||
return $items;
|
||||
}
|
||||
|
||||
// we can't do this if they tried to make the last path bit variable.
|
||||
// @todo: We can validate this.
|
||||
if (!empty($bits)) {
|
||||
// Assign the route name to the parent route, not the default tab.
|
||||
$default_route_name = $items[$path]['route_name'];
|
||||
unset($items[$path]['route_name']);
|
||||
|
||||
$default_path = implode('/', $bits);
|
||||
$items[$default_path] = array(
|
||||
// Default views page entry.
|
||||
// Identify URL embedded arguments and correlate them to a
|
||||
// handler.
|
||||
'load arguments' => array($this->view->storage->id(), $this->display['id'], '%index'),
|
||||
'title' => $tab_options['title'],
|
||||
'description' => $tab_options['description'],
|
||||
'menu_name' => $tab_options['name'],
|
||||
'route_name' => $default_route_name,
|
||||
);
|
||||
switch ($tab_options['type']) {
|
||||
default:
|
||||
case 'normal':
|
||||
$items[$default_path]['type'] = MENU_NORMAL_ITEM;
|
||||
break;
|
||||
}
|
||||
if (isset($tab_options['weight'])) {
|
||||
$items[$default_path]['weight'] = intval($tab_options['weight']);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $items;
|
||||
}
|
||||
|
||||
/**
|
||||
* Overrides \Drupal\views\Plugin\views\display\DisplayPluginBase::execute().
|
||||
*/
|
||||
|
|
|
@ -49,7 +49,7 @@ class FilterBooleanOperatorStringTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -45,7 +45,7 @@ class FilterBooleanOperatorTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -38,7 +38,7 @@ class FilterEqualityTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
|
|
|
@ -39,7 +39,7 @@ class FilterInOperatorTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
|
|
|
@ -39,7 +39,7 @@ class FilterNumericTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
|
|
|
@ -38,7 +38,7 @@ class FilterStringTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router', 'key_value_expire'));
|
||||
$this->installSchema('system', array('key_value_expire'));
|
||||
}
|
||||
|
||||
function viewsData() {
|
||||
|
|
|
@ -54,7 +54,7 @@ class DisplayPageTest extends ViewUnitTestBase {
|
|||
parent::setUp();
|
||||
|
||||
// Setup the needed tables in order to make the drupal router working.
|
||||
$this->installSchema('system', array('menu_router', 'url_alias'));
|
||||
$this->installSchema('system', array('url_alias'));
|
||||
$this->installSchema('menu_link', 'menu_links');
|
||||
}
|
||||
|
||||
|
|
|
@ -51,7 +51,6 @@ class RowEntityTest extends ViewUnitTestBase {
|
|||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installSchema('system', array('menu_router'));
|
||||
$this->installSchema('taxonomy', array('taxonomy_term_data', 'taxonomy_term_hierarchy'));
|
||||
$this->installConfig(array('taxonomy'));
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
|
|
@ -1511,28 +1511,6 @@ class ViewExecutable extends DependencySerialization {
|
|||
$this->is_attachment = FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Called to get hook_menu() information from the view and the named display handler.
|
||||
*
|
||||
* @param $display_id
|
||||
* A display id.
|
||||
* @param $callbacks
|
||||
* A menu callback array passed from views_menu_alter().
|
||||
*/
|
||||
public function executeHookMenu($display_id = NULL, &$callbacks = array()) {
|
||||
// Prepare the view with the information we have.
|
||||
|
||||
// This was probably already called, but it's good to be safe.
|
||||
if (!$this->setDisplay($display_id)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
// Execute the view
|
||||
if (isset($this->display_handler)) {
|
||||
return $this->display_handler->executeHookMenu($callbacks);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns default menu links from the view and the named display handler.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue