diff --git a/core/modules/aggregator/aggregator.routing.yml b/core/modules/aggregator/aggregator.routing.yml index 5ef55f0..2072e0d 100644 --- a/core/modules/aggregator/aggregator.routing.yml +++ b/core/modules/aggregator/aggregator.routing.yml @@ -139,7 +139,7 @@ aggregator.categorize_feed_form: _permission: 'administer news feeds' aggregator.opml_page: - pattern: '/aggregator/opml/{cid}' + path: '/aggregator/opml/{cid}' defaults: _content: '\Drupal\aggregator\Controller\AggregatorController::opmlPage' cid: null diff --git a/core/modules/block/block.routing.yml b/core/modules/block/block.routing.yml index c14f281..e4f16c1 100644 --- a/core/modules/block/block.routing.yml +++ b/core/modules/block/block.routing.yml @@ -1,5 +1,5 @@ block.admin_demo: - pattern: '/admin/structure/block/demo/{theme}' + path: '/admin/structure/block/demo/{theme}' defaults: _content: '\Drupal\block\Controller\BlockAdminController::demo' options: diff --git a/core/modules/comment/comment.module b/core/modules/comment/comment.module index 64fe92b..325ef10 100644 --- a/core/modules/comment/comment.module +++ b/core/modules/comment/comment.module @@ -185,10 +185,8 @@ function comment_menu() { $items['admin/content/comment'] = array( 'title' => 'Comments', 'description' => 'List and edit site comments and the comment approval queue.', - 'page callback' => 'comment_admin', - 'access arguments' => array('administer comments'), + 'route_name' => 'comment.admin', 'type' => MENU_LOCAL_TASK | MENU_NORMAL_ITEM, - 'file' => 'comment.admin.inc', ); // Tabs begin here. $items['admin/content/comment/new'] = array( diff --git a/core/modules/comment/comment.routing.yml b/core/modules/comment/comment.routing.yml index fb0a1c4..8c7774d 100644 --- a/core/modules/comment/comment.routing.yml +++ b/core/modules/comment/comment.routing.yml @@ -1,3 +1,12 @@ +comment.admin: + path: '/admin/content/comment' + defaults: + _title: 'Comments' + _content: '\Drupal\comment\Controller\CommentController::adminPage' + type: 'new' + requirements: + _permission: 'access comments' + comment.edit_page: path: '/comment/{comment}/edit' defaults: diff --git a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php index 48a23cd..7edf82c 100644 --- a/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php +++ b/core/modules/comment/lib/Drupal/comment/Controller/CommentController.php @@ -271,4 +271,12 @@ public function renderNewCommentsNodeLinks(Request $request) { return new JsonResponse($links); } + /** + * @see comment_admin() + */ + public function adminPage($type) { + module_load_include('admin.inc', 'comment'); + return comment_admin($type); + } + } diff --git a/core/modules/contact/contact.module b/core/modules/contact/contact.module index 18180f8..9a91a35 100644 --- a/core/modules/contact/contact.module +++ b/core/modules/contact/contact.module @@ -86,31 +86,22 @@ function contact_menu() { $items['contact'] = array( 'title' => 'Contact', - 'page callback' => 'contact_site_page', - 'access arguments' => array('access site-wide contact form'), + 'route_name' => 'contact.site_page', 'menu_name' => 'footer', 'type' => MENU_SUGGESTED_ITEM, - 'file' => 'contact.pages.inc', ); $items['contact/%contact_category'] = array( 'title' => 'Contact category form', 'title callback' => 'entity_page_label', 'title arguments' => array(1), - 'page callback' => 'contact_site_page', - 'page arguments' => array(1), - 'access arguments' => array('access site-wide contact form'), + 'route_name' => 'contact.site_page_category', 'type' => MENU_VISIBLE_IN_BREADCRUMB, - 'file' => 'contact.pages.inc', ); $items['user/%user/contact'] = array( 'title' => 'Contact', - 'page callback' => 'contact_personal_page', - 'page arguments' => array(1), + 'route_name' => 'contact.personal_page', 'type' => MENU_LOCAL_TASK, - 'access callback' => '_contact_personal_tab_access', - 'access arguments' => array(1), 'weight' => 2, - 'file' => 'contact.pages.inc', ); return $items; } @@ -124,41 +115,7 @@ function contact_menu() { * @see contact_menu() */ function _contact_personal_tab_access(UserInterface $account) { - global $user; - - // Anonymous users cannot have contact forms. - if ($account->isAnonymous()) { - return FALSE; - } - - // Users may not contact themselves. - if ($user->id() == $account->id()) { - return FALSE; - } - - // User administrators should always have access to personal contact forms. - if (user_access('administer users')) { - return TRUE; - } - - // If requested user has been blocked, do not allow users to contact them. - if ($account->isBlocked()) { - return FALSE; - } - - // If the requested user has disabled their contact form, do not allow users - // to contact them. - $account_data = \Drupal::service('user.data')->get('contact', $account->id(), 'enabled'); - if (isset($account_data) && empty($account_data)) { - return FALSE; - } - // If the requested user did not save a preference yet, deny access if the - // configured default is disabled. - elseif (!\Drupal::config('contact.settings')->get('user_default_enabled')) { - return FALSE; - } - - return user_access('access user contact forms'); + return \Drupal::service('access_manager')->checkNamedRoute('contact.personal_page'); } /** diff --git a/core/modules/contact/contact.routing.yml b/core/modules/contact/contact.routing.yml index 8c85b36..fed2e2b 100644 --- a/core/modules/contact/contact.routing.yml +++ b/core/modules/contact/contact.routing.yml @@ -25,3 +25,25 @@ contact.category_edit: _entity_form: contact_category.edit requirements: _entity_access: contact_category.update + +contact.site_page: + path: 'contact' + defaults: + _content: '\Drupal\contact\Controller\ContactPageController::contactSitePage' + contact_category: NULL + requirements: + _permission: 'access site-wide contact form' + +contact.site_page_category: + path: 'contact/{contact_category}' + defaults: + _content: '\Drupal\contact\Controller\ContactPageController::contactSitePage' + requirements: + _entity_access: 'contact_category.page' + +contact.personal_page: + path: 'user/{user}/contact' + defaults: + _content: '\Drupal\contact\Controller\ContactPageController::contactPersonalPage' + requirements: + _access_contact_personal_tab: 'TRUE' diff --git a/core/modules/contact/contact.services.yml b/core/modules/contact/contact.services.yml new file mode 100644 index 0000000..cccd1fd --- /dev/null +++ b/core/modules/contact/contact.services.yml @@ -0,0 +1,6 @@ +services: + access_check.contact_personal: + class: Drupal\contact\Access\ContactPageAccess + tags: + - { name: access_check } + arguments: ['@config.factory', '@user.data'] diff --git a/core/modules/contact/lib/Drupal/contact/Access/ContactPageAccess.php b/core/modules/contact/lib/Drupal/contact/Access/ContactPageAccess.php new file mode 100644 index 0000000..0bfee5c --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Access/ContactPageAccess.php @@ -0,0 +1,98 @@ +configFactory = $config_factory; + $this->userData = $user_data; + } + + /** + * {@inheritdoc} + */ + public function appliesTo() { + return array('_access_contact_personal_tab'); + } + + /** + * {@inheritdoc} + */ + public function access(Route $route, Request $request) { + $contact_account = $request->attributes->get('user'); + // @todo revisit after https://drupal.org/node/2048223 + $user = \Drupal::currentUser(); + + // Anonymous users cannot have contact forms. + if ($contact_account->isAnonymous()) { + return static::DENY; + } + + // Users may not contact themselves. + if ($user->id() == $contact_account->id()) { + return static::DENY; + } + + // User administrators should always have access to personal contact forms. + if ($user->hasPermission('administer users')) { + return static::ALLOW; + } + + // If requested user has been blocked, do not allow users to contact them. + if ($contact_account->isBlocked()) { + return static::DENY; + } + + // If the requested user has disabled their contact form, do not allow users + // to contact them. + $account_data = $this->userData->get('contact', $contact_account->id(), 'enabled'); + if (isset($account_data) && empty($account_data)) { + return static::DENY; + } + // If the requested user did not save a preference yet, deny access if the + // configured default is disabled. + else if (!$this->configFactory->get('contact.settings')->get('user_default_enabled')) { + return static::DENY; + } + + return $user->hasPermission('access user contact forms') ? static::ALLOW : static::DENY; + } + +} diff --git a/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php new file mode 100644 index 0000000..fc12d7b --- /dev/null +++ b/core/modules/contact/lib/Drupal/contact/Controller/ContactPageController.php @@ -0,0 +1,34 @@ + 'Content language settings', 'description' => 'Configure content language support for any multilingual element.', - 'page callback' => 'language_content_settings_page', - 'access arguments' => array('administer languages'), - 'file' => 'language.admin.inc', + 'route_name' => 'language.content_settings_page', ); return $items; diff --git a/core/modules/language/language.routing.yml b/core/modules/language/language.routing.yml index ae980ec..7494f1e 100644 --- a/core/modules/language/language.routing.yml +++ b/core/modules/language/language.routing.yml @@ -61,3 +61,11 @@ language.negotiation_browser_delete: _form: '\Drupal\language\Form\NegotiationBrowserDeleteForm' requirements: _permission: 'administer languages' + +language.content_settings_page: + path: '/admin/config/regional/content-language' + defaults: + _title: 'Content language settings' + _content: '\Drupal\language\Controller\LanguageController::contentSettings' + requirements: + _permission: 'administer languages' diff --git a/core/modules/language/lib/Drupal/language/Controller/LanguageController.php b/core/modules/language/lib/Drupal/language/Controller/LanguageController.php new file mode 100644 index 0000000..3fdd2a2 --- /dev/null +++ b/core/modules/language/lib/Drupal/language/Controller/LanguageController.php @@ -0,0 +1,23 @@ +attributes->get('_account'); + $account = \Drupal::currentUser(); $plugin_id = $route->getRequirement('_search_plugin_view_access'); return $this->searchManager->pluginAccess($plugin_id, $account) ? static::ALLOW : static::DENY; } diff --git a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php index 2c1c2a2..51a8219 100644 --- a/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php +++ b/core/modules/search/lib/Drupal/search/Routing/SearchRouteSubscriber.php @@ -53,7 +53,7 @@ public function routes(RouteBuildEvent $event) { $collection = $event->getRouteCollection(); foreach ($this->searchManager->getActiveDefinitions() as $plugin_id => $search_info) { - $path = 'search/' . $search_info['path']; + $path = 'search/' . $search_info['path'] . '/{keys}'; $defaults = array( '_content' => 'Drupal\search\Controller\SearchController::searchViewPlugin', 'plugin_id' => $plugin_id, diff --git a/core/modules/search/search.routing.yml b/core/modules/search/search.routing.yml index 5c05727..6961cb4 100644 --- a/core/modules/search/search.routing.yml +++ b/core/modules/search/search.routing.yml @@ -13,7 +13,7 @@ search.reindex_confirm: _permission: 'administer search' search.view: - pattern: '/search' + path: '/search' defaults: _content: '\Drupal\search\Controller\SearchController::searchView' options: diff --git a/core/modules/system/system.routing.yml b/core/modules/system/system.routing.yml index ad86ff8..772090e 100644 --- a/core/modules/system/system.routing.yml +++ b/core/modules/system/system.routing.yml @@ -281,7 +281,7 @@ system.files: _access: 'TRUE' system.temporary: - pattern: '/system/temporary' + path: '/system/temporary' defaults: _controller: '\Drupal\system\FileDownloadController::download' scheme: temporary @@ -289,7 +289,7 @@ system.temporary: _access: 'TRUE' system.themes_page: - pattern: '/admin/appearance' + path: '/admin/appearance' defaults: _title: 'Appearance' _content: '\Drupal\system\Controller\SystemController::themesPage' @@ -297,7 +297,7 @@ system.themes_page: _permission: 'administer themes' system.theme_set_default: - pattern: '/admin/appearance/default' + path: '/admin/appearance/default' defaults: _title: 'Set default theme' _content: '\Drupal\system\Controller\SystemController::themeSetDefault' diff --git a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php index 938cc7b..79c17c3 100644 --- a/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php +++ b/core/modules/taxonomy/lib/Drupal/taxonomy/Controller/TaxonomyController.php @@ -8,6 +8,7 @@ namespace Drupal\taxonomy\Controller; use Drupal\Core\Controller\ControllerBase; +use Drupal\taxonomy\TermInterface; use Drupal\taxonomy\VocabularyInterface; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -33,4 +34,20 @@ public function addForm(VocabularyInterface $taxonomy_vocabulary) { return $this->entityManager()->getForm($term); } + /** + * @see taxonomy_term_page() + */ + public function termPage(TermInterface $taxonomy_term) { + module_load_include('pages.inc', 'taxonomy'); + return taxonomy_term_page($taxonomy_term); + } + + /** + * @see taxonomy_term_feed() + */ + public function termFeed(TermInterface $taxonomy_term) { + module_load_include('pages.inc', 'taxonomy'); + return taxonomy_term_feed($taxonomy_term); + } + } diff --git a/core/modules/taxonomy/taxonomy.module b/core/modules/taxonomy/taxonomy.module index 1df57d3..81537b6 100644 --- a/core/modules/taxonomy/taxonomy.module +++ b/core/modules/taxonomy/taxonomy.module @@ -250,11 +250,7 @@ function taxonomy_menu() { 'title' => 'Taxonomy term', 'title callback' => 'taxonomy_term_title', 'title arguments' => array(2), - 'page callback' => 'taxonomy_term_page', - 'page arguments' => array(2), - 'access callback' => 'entity_page_access', - 'access arguments' => array(2, 'view'), - 'file' => 'taxonomy.pages.inc', + 'route_name' => 'taxonomy.term_page', ); $items['taxonomy/term/%taxonomy_term/view'] = array( 'title' => 'View', @@ -280,12 +276,8 @@ function taxonomy_menu() { 'title' => 'Taxonomy term', 'title callback' => 'taxonomy_term_title', 'title arguments' => array(2), - 'page callback' => 'taxonomy_term_feed', - 'page arguments' => array(2), - 'access callback' => 'entity_page_access', - 'access arguments' => array(2, 'view'), + 'route_name' => 'taxonomy.term_feed', 'type' => MENU_CALLBACK, - 'file' => 'taxonomy.pages.inc', ); $items['admin/structure/taxonomy/manage/%taxonomy_vocabulary'] = array( diff --git a/core/modules/taxonomy/taxonomy.routing.yml b/core/modules/taxonomy/taxonomy.routing.yml index f1b9d82..8e024a0 100644 --- a/core/modules/taxonomy/taxonomy.routing.yml +++ b/core/modules/taxonomy/taxonomy.routing.yml @@ -75,3 +75,16 @@ taxonomy.overview_terms: requirements: _entity_access: 'taxonomy_vocabulary.view' +taxonomy.term_page: + path: '/taxonomy/term/{taxonomy_term}' + defaults: + _content: '\Drupal\taxonomy\Controller\TaxonomyController::termPage' + requirements: + _entity_access: 'taxonomy_term.view' + +taxonomy.term_feed: + path: '/taxonomy/term/{taxonomy_term}/feed' + defaults: + _content: '\Drupal\taxonomy\Controller\TaxonomyController::termFeed' + requirements: + _entity_access: 'taxonomy_term.view' diff --git a/core/modules/update/update.routing.yml b/core/modules/update/update.routing.yml index 6100e8a..43ae6b5 100644 --- a/core/modules/update/update.routing.yml +++ b/core/modules/update/update.routing.yml @@ -13,7 +13,7 @@ update.status: _permission: 'administer site configuration' update.manual_status: - pattern: '/admin/reports/updates/check' + path: '/admin/reports/updates/check' defaults: _title: 'Manual update check' _content: '\Drupal\update\Controller\UpdateController::updateStatusManually' diff --git a/core/modules/user/user.routing.yml b/core/modules/user/user.routing.yml index b3e4b2e..6a9c057 100644 --- a/core/modules/user/user.routing.yml +++ b/core/modules/user/user.routing.yml @@ -112,7 +112,7 @@ user.page: _access: 'TRUE' user.view: - pattern: '/user/{user}' + path: '/user/{user}' defaults: _entity_view: 'user.full' requirements: @@ -142,7 +142,7 @@ user.cancel: _entity_access: 'user.delete' user.cancel_confirm: - pattern: '/user/{user}/cancel/confirm/{timestamp}/{hashed_pass}' + path: '/user/{user}/cancel/confirm/{timestamp}/{hashed_pass}' defaults: _title: 'Confirm account cancellation' _content: '\Drupal\user\Controller\UserController::confirmCancel' diff --git a/core/modules/xmlrpc/xmlrpc.routing.yml b/core/modules/xmlrpc/xmlrpc.routing.yml index 6be284d..822b274 100644 --- a/core/modules/xmlrpc/xmlrpc.routing.yml +++ b/core/modules/xmlrpc/xmlrpc.routing.yml @@ -1,5 +1,5 @@ xmlrpc.php: - pattern: '/xmlrpc.php' + path: '/xmlrpc.php' defaults: _content: '\Drupal\xmlrpc\Controller\XmlrpcController::php' requirements: diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md index f0c616d..c15ab7d 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/CHANGELOG.md @@ -18,7 +18,7 @@ CHANGELOG ``` article_edit: - pattern: /article/{id} + path: /article/{id} requirements: { '_method': 'POST|PUT', '_scheme': 'https', 'id': '\d+' } diff --git a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml index 4ada883..132efbf 100644 --- a/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml +++ b/core/vendor/symfony/routing/Symfony/Component/Routing/Tests/Fixtures/validpattern.yml @@ -9,7 +9,7 @@ blog_show: compiler_class: RouteCompiler blog_show_legacy: - pattern: /blog/{slug} + path: /blog/{slug} defaults: { _controller: "MyBundle:Blog:show" } host: "{locale}.example.com" requirements: { '_method': 'GET|POST|put|OpTiOnS', _scheme: https, 'locale': '\w+' }