diff --git c/core/modules/book/book.module w/core/modules/book/book.module index 8ed85c4..d817f04 100644 --- c/core/modules/book/book.module +++ w/core/modules/book/book.module @@ -195,11 +195,7 @@ function book_menu() { ); $items['node/%node/outline/remove'] = array( 'title' => 'Remove from outline', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('book_remove_form', 1), - 'access callback' => '_book_outline_remove_access', - 'access arguments' => array(1), - 'file' => 'book.pages.inc', + 'route_name' => 'book.remove', ); return $items; diff --git c/core/modules/book/book.routing.yml w/core/modules/book/book.routing.yml index 733ae8c..ce5e22a 100644 --- c/core/modules/book/book.routing.yml +++ w/core/modules/book/book.routing.yml @@ -50,3 +50,15 @@ book.admin_edit: _permission: 'administer book outlines' _entity_access: 'node.view' node: \d+ + +book.remove: + pattern: '/node/{node}/outline/remove' + defaults: + _content: '\Drupal\book\Form\BookForm::remove' + _title: 'Remove from outline' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer book outlines' + _entity_access: 'node.view' + _book_node_is_removable: 'TRUE' diff --git c/core/modules/book/book.services.yml w/core/modules/book/book.services.yml index 510573a..2f1097a 100644 --- c/core/modules/book/book.services.yml +++ w/core/modules/book/book.services.yml @@ -5,3 +5,9 @@ services: book.export: class: Drupal\book\BookExport arguments: ['@entity.manager'] + + access_check.book.removable: + class: Drupal\book\Access\BookNodeIsRemovableAccessCheck + arguments: ['@book.manager'] + tags: + - { name: access_check } diff --git c/core/modules/book/lib/Drupal/book/Access/BookNodeIsRemovableAccessCheck.php w/core/modules/book/lib/Drupal/book/Access/BookNodeIsRemovableAccessCheck.php new file mode 100644 index 0000000..eb8bb28 --- /dev/null +++ w/core/modules/book/lib/Drupal/book/Access/BookNodeIsRemovableAccessCheck.php @@ -0,0 +1,55 @@ +bookManager = $book_manager; + } + + /** + * {@inheritdoc} + */ + public function applies(Route $route) { + return array_key_exists('_book_node_is_removable', $route->getRequirements()); + } + + /** + * {@inheritdoc} + */ + public function access(Route $route, Request $request) { + $node = $request->attributes->get('node'); + if (!empty($node)) { + return $this->bookManager->checkNodeIsRemovable($node) ? static::ALLOW : static::DENY; + } + return static::DENY; + } + +} diff --git c/core/modules/book/lib/Drupal/book/Form/BookForm.php w/core/modules/book/lib/Drupal/book/Form/BookForm.php new file mode 100644 index 0000000..9ed431a --- /dev/null +++ w/core/modules/book/lib/Drupal/book/Form/BookForm.php @@ -0,0 +1,25 @@ + 'Delete', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('content_translation_delete_confirm', $entity_position, $language_position), - 'access callback' => 'content_translation_delete_access', - 'access arguments' => $args, + 'route_name' => "content_translation.delete_$entity_type", ) + $item; } } diff --git c/core/modules/content_translation/content_translation.services.yml w/core/modules/content_translation/content_translation.services.yml index 678724d..c6514bc 100644 --- c/core/modules/content_translation/content_translation.services.yml +++ w/core/modules/content_translation/content_translation.services.yml @@ -2,3 +2,15 @@ services: content_translation.synchronizer: class: Drupal\content_translation\FieldTranslationSynchronizer arguments: ['@entity.manager'] + + content_translation.subscriber: + class: Drupal\content_translation\Routing\ContentTranslationRouteSubscriber + arguments: ['@plugin.manager.entity'] + tags: + - { name: event_subscriber } + + content_translation.manage_access: + class: Drupal\content_translation\Access\ContentTranslationManageAccessCheck + arguments: ['@plugin.manager.entity'] + tags: + - { name: access_check } diff --git c/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php w/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php new file mode 100644 index 0000000..cd8c855 --- /dev/null +++ w/core/modules/content_translation/lib/Drupal/content_translation/Access/ContentTranslationManageAccessCheck.php @@ -0,0 +1,71 @@ +entityManager = $manager; + } + + /** + * {@inheritdoc} + */ + public function applies(Route $route) { + return array_key_exists('_access_content_translation_manage', $route->getRequirements()); + } + + /** + * {@inheritdoc} + */ + public function access(Route $route, Request $request) { + if ($entity = $request->attributes->get('entity')) { + $operation = $route->getRequirement('_access_content_translation_manage'); + $entity_type = $entity->entityType(); + $controller_class = $this->entityManager->getControllerClass($entity_type, 'translation'); + $controller = new $controller_class($entity_type, $entity->entityInfo()); + + // Load translation. + $translations = $entity->getTranslationLanguages(); + $languages = language_list(); + + if ($operation == 'delete') { + $language = $request->attributes->get('language'); + $language = !empty($language) ? $language : language(Language::TYPE_CONTENT); + return isset($languages[$language->id]) + && $language->id != $entity->getUntranslated()->language()->id + && isset($translations[$language->id]) + && $controller->getTranslationAccess($entity, $operation) + ? static::ALLOW : static::DENY; + } + } + return static::DENY; + } +} diff --git c/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php w/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php new file mode 100644 index 0000000..11ad270 --- /dev/null +++ w/core/modules/content_translation/lib/Drupal/content_translation/Form/ContentTranslationForm.php @@ -0,0 +1,26 @@ +entityManager = $entityManager; + } + + /** + * {@inheritdoc} + */ + public static function getSubscribedEvents() { + $events[RoutingEvents::DYNAMIC] = 'routes'; + return $events; + } + + /** + * Adds routes for entity translations. + */ + public function routes(RouteBuildEvent $event) { + $collection = $event->getRouteCollection(); + foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) { + if ($entity_info['translatable'] && isset($entity_info['translation'])) { + $route = new Route( + '/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . "/translations/delete/{language}", + array( + '_content' => '\Drupal\content_translation\Form\ContentTranslationForm', + 'language' => NULL, + '_title' => 'Delete', + ), + array( + '_permission' => 'translate any entity', + '_access_content_translation_manage' => 'delete', + ), + array( + 'parameters' => array( + 'entity' => array( + 'type' => 'entity:' . $entity_type, + ), + 'language' => array( + 'type' => 'language', + ), + ), + ) + ); + $collection->add("content_translation.delete_$entity_type", $route); + } + } + } +} diff --git c/core/modules/language/language.module w/core/modules/language/language.module index 216211b..2233389 100644 --- c/core/modules/language/language.module +++ w/core/modules/language/language.module @@ -92,11 +92,8 @@ function language_menu() { // Language negotiation. $items['admin/config/regional/language/detection'] = array( 'title' => 'Detection and selection', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('language_negotiation_configure_form'), - 'access arguments' => array('administer languages'), + 'route_name' => 'language.negotiation', 'weight' => 10, - 'file' => 'language.admin.inc', 'type' => MENU_LOCAL_TASK, ); $items['admin/config/regional/language/detection/url'] = array( diff --git c/core/modules/language/language.routing.yml w/core/modules/language/language.routing.yml index f79da8d..7a9dbcb 100644 --- c/core/modules/language/language.routing.yml +++ w/core/modules/language/language.routing.yml @@ -61,3 +61,11 @@ language.negotiation_browser_delete: _form: '\Drupal\language\Form\NegotiationBrowserDeleteForm' requirements: _permission: 'administer languages' + +language.negotiation: + pattern: '/admin/config/regional/language/detection' + defaults: + _content: '\Drupal\language\Form\LanguageForm::negotiation' + _title: 'Detection and selection' + requirements: + _permission: 'administer languages' diff --git c/core/modules/language/lib/Drupal/language/Form/LanguageForm.php w/core/modules/language/lib/Drupal/language/Form/LanguageForm.php new file mode 100644 index 0000000..17773ff --- /dev/null +++ w/core/modules/language/lib/Drupal/language/Form/LanguageForm.php @@ -0,0 +1,23 @@ + 'Import', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('locale_translate_import_form'), - 'access arguments' => array('translate interface'), + 'route_name' => 'locale.translate_import', 'weight' => 20, 'type' => MENU_LOCAL_TASK, - 'file' => 'locale.bulk.inc', ); $items['admin/config/regional/translate/export'] = array( 'title' => 'Export', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('locale_translate_export_form'), - 'access arguments' => array('translate interface'), + 'route_name' => 'locale.translate_export', 'weight' => 30, 'type' => MENU_LOCAL_TASK, - 'file' => 'locale.bulk.inc', ); $items['admin/config/regional/translate/settings'] = array( 'title' => 'Settings', @@ -206,11 +200,8 @@ function locale_menu() { ); $items['admin/reports/translations'] = array( 'title' => 'Available translation updates', + 'route_name' => 'locale.translate_status', 'description' => 'Get a status report about available interface translations for your installed modules and themes.', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('locale_translation_status_form'), - 'access arguments' => array('translate interface'), - 'file' => 'locale.pages.inc', ); return $items; diff --git c/core/modules/locale/locale.routing.yml w/core/modules/locale/locale.routing.yml index cbbfc00..6af4ccc 100644 --- c/core/modules/locale/locale.routing.yml +++ w/core/modules/locale/locale.routing.yml @@ -18,3 +18,27 @@ locale.translate_page: _content: 'Drupal\locale\Controller\LocaleController::translatePage' requirements: _permission: 'translate interface' + +locale.translate_import: + pattern: '/admin/config/regional/translate/import' + defaults: + _content: '\Drupal\locale\Form\LocaleForm::import' + _title: 'Import' + requirements: + _permission: 'translate interface' + +locale.translate_export: + pattern: '/admin/config/regional/translate/export' + defaults: + _content: '\Drupal\locale\Form\LocaleForm::export' + _title: 'Export' + requirements: + _permission: 'translate interface' + +locale.translate_status: + pattern: '/admin/reports/translations' + defaults: + _content: '\Drupal\locale\Form\LocaleForm::status' + _title: 'Available translation updates' + requirements: + _permission: 'translate interface' diff --git c/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php w/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php new file mode 100644 index 0000000..030fa0a --- /dev/null +++ w/core/modules/shortcut/lib/Drupal/shortcut/Form/ShortcutForm.php @@ -0,0 +1,47 @@ + 'Add shortcut', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('shortcut_link_add', 5), - 'access callback' => 'shortcut_set_edit_access', - 'access arguments' => array(5), + 'route_name' => 'shortcut.edit', 'type' => MENU_LOCAL_ACTION, - 'file' => 'shortcut.admin.inc', ); $items['admin/config/user-interface/shortcut/link/%menu_link'] = array( 'title' => 'Edit shortcut', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('shortcut_link_edit', 5), - 'access callback' => 'shortcut_link_access', - 'access arguments' => array(5), - 'file' => 'shortcut.admin.inc', + 'route_name' => 'shortcut.edit', ); $items['admin/config/user-interface/shortcut/link/%menu_link/delete'] = array( 'title' => 'Delete shortcut', @@ -138,12 +130,8 @@ function shortcut_menu() { ); $items['user/%user/shortcuts'] = array( 'title' => 'Shortcuts', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('shortcut_set_switch', 1), - 'access callback' => 'shortcut_set_switch_access', - 'access arguments' => array(1), + 'route_name' => 'shortcut.overview', 'type' => MENU_LOCAL_TASK, - 'file' => 'shortcut.admin.inc', ); return $items; diff --git c/core/modules/shortcut/shortcut.routing.yml w/core/modules/shortcut/shortcut.routing.yml index 0745206..9d790ef 100644 --- c/core/modules/shortcut/shortcut.routing.yml +++ w/core/modules/shortcut/shortcut.routing.yml @@ -46,3 +46,32 @@ shortcut.set_customize: _entity_form: 'shortcut_set.customize' requirements: _entity_access: 'shortcut_set.update' + +shortcut.add_link: + pattern: '/admin/config/user-interface/shortcut/manage/{shortcut_set}/add-link' + defaults: + _content: '\Drupal\shortcut\Form\ShortcutForm::add' + _title: 'Add Shortcut' + requirements: + _access: 'TRUE' + +shortcut.edit_link: + pattern: '/admin/config/user-interface/shortcut/link/{menu_link}' + defaults: + _content: '\Drupal\shortcut\Form\ShortcutForm::edit' + _title: 'Add Shortcut' + options: + _access_checks: 'ALL' + requirements: + _access: 'TRUE' + +shortcut.overview: + pattern: 'user/{user}/shortcuts' + defaults: + _content: '\Drupal\shortcut\Form\ShortcutForm::overview' + _title: 'Add Shortcut' + options: + _access_checks: 'ALL' + requirements: + _access: 'TRUE' + diff --git c/core/modules/system/lib/Drupal/system/Form/SystemForm.php w/core/modules/system/lib/Drupal/system/Form/SystemForm.php new file mode 100644 index 0000000..e3b4021 --- /dev/null +++ w/core/modules/system/lib/Drupal/system/Form/SystemForm.php @@ -0,0 +1,23 @@ + 'Localize date formats', + 'route_name' => 'system.localize_date_format', 'description' => 'Configure date formats for each locale', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('system_date_format_localize_form', 5), - 'access arguments' => array('administer site configuration'), - 'file' => 'system.admin.inc', ); $items['admin/config/regional/date-time/locale/%/reset'] = array( 'title' => 'Reset date formats', diff --git c/core/modules/system/system.routing.yml w/core/modules/system/system.routing.yml index f8eed28..0ef8154 100644 --- c/core/modules/system/system.routing.yml +++ w/core/modules/system/system.routing.yml @@ -326,3 +326,11 @@ system.batch_page: _controller: '\Drupal\system\Controller\BatchController::batchPage' requirements: _access: 'TRUE' + +system.localize_date_format: + pattern: '/admin/config/regional/date-time/locale/{langcode}/edit' + defaults: + _content: '\Drupal\system\Form\SystemForm::localizeDateFormat' + _title: 'Localize date formats' + requirements: + _permission: 'administer site configuration' diff --git c/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccessCheck.php w/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccessCheck.php new file mode 100644 index 0000000..44b4beb --- /dev/null +++ w/core/modules/update/lib/Drupal/update/Access/UpdateManagerAccessCheck.php @@ -0,0 +1,51 @@ +settings = $settings; + } + + /** + * {@inheritdoc} + */ + public function applies(Route $route) { + return array_key_exists('_access_update_manager', $route->getRequirements()); + } + + /** + * {@inheritdoc} + */ + public function access(Route $route, Request $request) { + return $settings->get('allow_authorize_operations', TRUE) ? static::ALLOW : static::DENY; + } + +} diff --git c/core/modules/update/lib/Drupal/update/Form/UpdateForm.php w/core/modules/update/lib/Drupal/update/Form/UpdateForm.php new file mode 100644 index 0000000..9832c17 --- /dev/null +++ w/core/modules/update/lib/Drupal/update/Form/UpdateForm.php @@ -0,0 +1,83 @@ + $path) { $items[$path . '/install'] = array( - 'page callback' => 'drupal_get_form', - 'page arguments' => array('update_manager_install_form', $context), - 'access callback' => 'update_manager_access', - 'access arguments' => array(), + 'route_name' => "update.{$context}_install", 'weight' => 25, 'type' => MENU_LOCAL_ACTION, - 'file' => 'update.manager.inc', ); $items[$path . '/update'] = array( - 'page callback' => 'drupal_get_form', - 'page arguments' => array('update_manager_update_form', $context), - 'access callback' => 'update_manager_access', - 'access arguments' => array(), + 'route_name' => "update.{$context}_update", 'weight' => 10, 'title' => 'Update', 'type' => MENU_LOCAL_TASK, - 'file' => 'update.manager.inc', ); } // Customize the titles of the action links depending on where they appear. @@ -219,18 +211,6 @@ function update_menu() { $items['admin/modules/install'] += array('title' => 'Install new module'); $items['admin/appearance/install'] += array('title' => 'Install new theme'); - // Menu callback used for the confirmation page after all the releases - // have been downloaded, asking you to backup before installing updates. - $items['admin/update/ready'] = array( - 'title' => 'Ready to update', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('update_manager_update_ready_form'), - 'access callback' => 'update_manager_access', - 'access arguments' => array(), - 'type' => MENU_CALLBACK, - 'file' => 'update.manager.inc', - ); - return $items; } diff --git c/core/modules/update/update.routing.yml w/core/modules/update/update.routing.yml index 4219734..2417c34 100644 --- c/core/modules/update/update.routing.yml +++ w/core/modules/update/update.routing.yml @@ -11,3 +11,77 @@ update.status: _content: '\Drupal\update\Controller\UpdateController::updateStatus' requirements: _permission: 'administer site configuration' + +update.report_install: + pattern: '/admin/reports/updates/install' + defaults: + _content: '\Drupal\update\Form\UpdateForm::reportInstall' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.report_update: + pattern: '/admin/reports/updates/update' + defaults: + _content: '\Drupal\update\Form\UpdateForm::reportUpdate' + _title: 'Update' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.module_install: + pattern: '/admin/modules/install' + defaults: + _content: '\Drupal\update\Form\UpdateForm::moduleInstall' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.module_update: + pattern: '/admin/modules/update' + defaults: + _content: '\Drupal\update\Form\UpdateForm::moduleUpdate' + _title: 'Update' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.theme_install: + pattern: '/admin/theme/install' + defaults: + _content: '\Drupal\update\Form\UpdateForm::themeInstall' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.theme_update: + pattern: '/admin/theme/update' + defaults: + _content: '\Drupal\update\Form\UpdateForm::themeUpdate' + _title: 'Update' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' + +update.confirmation_page: + pattern: '/admin/update/ready' + defaults: + _content: '\Drupal\update\Form\UpdateForm::confirmUpdates' + _title: 'Ready to update' + options: + _access_checks: 'ALL' + requirements: + _permission: 'administer software updates' + _access_update_manager: 'TRUE' diff --git c/core/modules/update/update.services.yml w/core/modules/update/update.services.yml new file mode 100644 index 0000000..0ffafc2 --- /dev/null +++ w/core/modules/update/update.services.yml @@ -0,0 +1,6 @@ +services: + access_check.update.manager_access: + class: Drupal\update\Access\UpdateManagerAccessCheck + arguments: ['@settings'] + tags: + - { name: access_check } diff --git c/core/modules/user/lib/Drupal/user/Form/UserForm.php w/core/modules/user/lib/Drupal/user/Form/UserForm.php new file mode 100644 index 0000000..18744cc --- /dev/null +++ w/core/modules/user/lib/Drupal/user/Form/UserForm.php @@ -0,0 +1,23 @@ + 'user.pass', 'type' => MENU_LOCAL_TASK, ); - $items['user/reset/%/%/%'] = array( - 'title' => 'Reset password', - 'page callback' => 'drupal_get_form', - 'page arguments' => array('user_pass_reset', 2, 3, 4), - 'access callback' => TRUE, - 'type' => MENU_CALLBACK, - 'file' => 'user.pages.inc', - ); $items['user/logout'] = array( 'title' => 'Log out', diff --git c/core/modules/user/user.routing.yml w/core/modules/user/user.routing.yml index ea4ce37..24f9170 100644 --- c/core/modules/user/user.routing.yml +++ w/core/modules/user/user.routing.yml @@ -132,3 +132,12 @@ user.cancel_confirm: _entity_form: 'user.cancel' requirements: _entity_access: 'user.delete' + +user.reset: + pattern: '/user/reset/{uid}/{timestamp}/{hash}/{operation}' + defaults: + _content: '\Drupal\user\Form\UserForm::resetPass' + _title: 'Reset password' + operation: NULL + requirements: + _access: 'TRUE'