Issue #2089671 by disasm, tim.plunkett: Convert non-test form callbacks to new form controller.

8.0.x
Alex Pott 2013-09-21 13:42:43 +02:00
parent b13a82c2bb
commit 523c8b6cb0
42 changed files with 782 additions and 98 deletions

View File

@ -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;

View File

@ -30,6 +30,8 @@ function book_remove_button_submit($form, &$form_state) {
* @see book_remove_form_submit()
* @see book_menu()
* @ingroup forms
*
* @deprecated Use \Drupal\book\Form\BookForm::remove()
*/
function book_remove_form($form, &$form_state, EntityInterface $node) {
$form['#node'] = $node;

View File

@ -50,3 +50,15 @@ book.admin_edit:
_permission: 'administer book outlines'
_entity_access: 'node.view'
node: \d+
book.remove:
path: '/node/{node}/outline/remove'
defaults:
_content: '\Drupal\book\Form\BookForm::remove'
_title: 'Remove from outline'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer book outlines'
_entity_access: 'node.view'
_access_book_removable: 'TRUE'

View File

@ -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 }

View File

@ -0,0 +1,55 @@
<?php
/**
* @file
* Contains Drupal\book\Access\BookNodeIsRemovableAccessCheck.
*/
namespace Drupal\book\Access;
use Drupal\book\BookManager;
use Drupal\Core\Access\StaticAccessCheckInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Determines whether the requested node can be removed from its book.
*/
class BookNodeIsRemovableAccessCheck implements StaticAccessCheckInterface {
/**
* Book Manager Service.
*
* @var \Drupal\book\BookManager
*/
protected $bookManager;
/**
* Constructs a BookNodeIsRemovableAccessCheck object.
*
* @param \Drupal\book\BookManager $book_manager
* Book Manager Service.
*/
public function __construct(BookManager $book_manager) {
$this->bookManager = $book_manager;
}
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_access_book_removable');
}
/**
* {@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;
}
}

View File

@ -0,0 +1,26 @@
<?php
/**
* @file
* Contains \Drupal\book\Form\BookForm.
*/
namespace Drupal\book\Form;
use Drupal\Core\Entity\EntityInterface;
/**
* Temporary form controller for book module.
*/
class BookForm {
/**
* Wraps book_remove_form().
*
* @todo Remove book_remove_form().
*/
public function remove(EntityInterface $node) {
module_load_include('pages.inc', 'book');
return drupal_get_form('book_remove_form', $node);
}
}

View File

@ -183,10 +183,7 @@ function content_translation_menu() {
// Delete translation callback.
$items["$path/translations/delete/%language"] = array(
'title' => '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;
}
}

View File

@ -248,6 +248,8 @@ function content_translation_prepare_translation(EntityInterface $entity, Langua
/**
* Form constructor for the translation deletion confirmation.
*
* @deprecated Use \Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation()
*/
function content_translation_delete_confirm(array $form, array $form_state, EntityInterface $entity, Language $language) {
$langcode = $language->id;

View File

@ -57,26 +57,28 @@ class ContentTranslationManageAccessCheck implements StaticAccessCheckInterface
$translations = $entity->getTranslationLanguages();
$languages = language_list();
if ($operation == 'create') {
$source = language_load($request->attributes->get('source'));
$target = language_load($request->attributes->get('target'));
$source = !empty($source) ? $source : $entity->language();
$target = !empty($target) ? $target : language(Language::TYPE_CONTENT);
return ($source->id != $target->id
&& isset($languages[$source->id])
&& isset($languages[$target->id])
&& !isset($translations[$target->id])
&& $controller->getTranslationAccess($entity, $operation))
? static::ALLOW : static::DENY;
}
elseif ($operation == 'update') {
$language = language_load($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;
switch ($operation) {
case 'create':
$source = language_load($request->attributes->get('source'));
$target = language_load($request->attributes->get('target'));
$source = !empty($source) ? $source : $entity->language();
$target = !empty($target) ? $target : language(Language::TYPE_CONTENT);
return ($source->id != $target->id
&& isset($languages[$source->id])
&& isset($languages[$target->id])
&& !isset($translations[$target->id])
&& $controller->getTranslationAccess($entity, $operation))
? static::ALLOW : static::DENY;
case 'update':
case 'delete':
$language = language_load($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;

View File

@ -0,0 +1,28 @@
<?php
/**
* @file
* Contains \Drupal\content_translation\Form\ContentTranslationForm.
*/
namespace Drupal\content_translation\Form;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Language\Language;
/**
* Temporary form controller for content_translation module.
*/
class ContentTranslationForm {
/**
* Wraps content_translation_delete_confirm().
*
* @todo Remove content_translation_delete_confirm().
*/
public function deleteTranslation(EntityInterface $entity, $language) {
module_load_include('pages.inc', 'content_translation');
$language = language_load($language);
return drupal_get_form('content_translation_delete_confirm', $entity, $language);
}
}

View File

@ -50,8 +50,9 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
$collection = $event->getRouteCollection();
foreach ($this->entityManager->getDefinitions() as $entity_type => $entity_info) {
if ($entity_info['translatable'] && isset($entity_info['translation'])) {
$path = '/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . '/translations';
$route = new Route(
'/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . "/translations",
$path,
array(
'_content' => '\Drupal\content_translation\Controller\ContentTranslationController::overview',
'_title' => 'Translate',
@ -72,7 +73,7 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
$collection->add("content_translation.translation_overview_$entity_type", $route);
$route = new Route(
'/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . "/translations/add/{source}/{target}",
$path . '/add/{source}/{target}',
array(
'_content' => '\Drupal\content_translation\Controller\ContentTranslationController::add',
'source' => NULL,
@ -95,7 +96,7 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
$collection->add("content_translation.translation_add_$entity_type", $route);
$route = new Route(
'/' . str_replace($entity_info['menu_path_wildcard'], '{entity}', $entity_info['menu_base_path']) . "/translations/edit/{language}",
$path . '/edit/{language}',
array(
'_content' => '\Drupal\content_translation\Controller\ContentTranslationController::edit',
'language' => NULL,
@ -114,6 +115,27 @@ class ContentTranslationRouteSubscriber implements EventSubscriberInterface {
)
);
$collection->add("content_translation.translation_edit_$entity_type", $route);
$route = new Route(
$path . '/delete/{language}',
array(
'_content' => '\Drupal\content_translation\Form\ContentTranslationForm::deleteTranslation',
'language' => NULL,
'_title' => 'Delete',
),
array(
'_permission' => 'translate any entity',
'_access_content_translation_manage' => 'delete',
),
array(
'parameters' => array(
'entity' => array(
'type' => 'entity:' . $entity_type,
),
),
)
);
$collection->add("content_translation.delete_$entity_type", $route);
}
}
}

View File

@ -26,6 +26,8 @@ function language_admin_predefined_list() {
/**
* Builds the configuration form for language negotiation.
*
* @deprecated Use \Drupal\language\Form\LanguageForm::negotiation()
*/
function language_negotiation_configure_form() {
language_negotiation_include();

View File

@ -94,11 +94,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(

View File

@ -47,6 +47,14 @@ language.delete:
requirements:
_entity_access: 'language_entity.delete'
language.negotiation:
path: '/admin/config/regional/language/detection'
defaults:
_content: '\Drupal\language\Form\LanguageForm::negotiation'
_title: 'Detection and selection'
requirements:
_permission: 'administer languages'
language.negotiation_browser:
path: '/admin/config/regional/language/detection/browser'
defaults:

View File

@ -0,0 +1,24 @@
<?php
/**
* @file
* Contains \Drupal\language\Form\LanguageForm.
*/
namespace Drupal\language\Form;
/**
* Temporary form controller for language module.
*/
class LanguageForm {
/**
* Wraps language_negotiation_configure_form().
*
* @todo Remove language_negotiation_configure_form().
*/
public function negotiation() {
module_load_include('admin.inc', 'language');
return drupal_get_form('language_negotiation_configure_form');
}
}

View File

@ -0,0 +1,44 @@
<?php
/**
* @file
* Contains \Drupal\locale\Form\LocaleForm.
*/
namespace Drupal\locale\Form;
/**
* Temporary form controller for locale module.
*/
class LocaleForm {
/**
* Wraps locale_translate_import_form().
*
* @todo Remove locale_translate_import_form().
*/
public function import() {
module_load_include('bulk.inc', 'locale');
return drupal_get_form('locale_translate_import_form');
}
/**
* Wraps locale_translate_export_form().
*
* @todo Remove locale_translate_export_form().
*/
public function export() {
module_load_include('bulk.inc', 'locale');
return drupal_get_form('locale_translate_export_form');
}
/**
* Wraps locale_translation_status_form().
*
* @todo Remove locale_translation_status_form().
*/
public function status() {
module_load_include('pages.inc', 'locale');
return drupal_get_form('locale_translation_status_form');
}
}

View File

@ -17,6 +17,8 @@ use Drupal\file\FileInterface;
*
* @see locale_translate_import_form_submit()
* @ingroup forms
*
* @deprecated Use \Drupal\locale\Form\LocaleForm::import()
*/
function locale_translate_import_form($form, &$form_state) {
drupal_static_reset('language_list');
@ -144,6 +146,8 @@ function locale_translate_import_form_submit($form, &$form_state) {
*
* @see locale_translate_export_form_submit()
* @ingroup forms
*
* @deprecated Use \Drupal\locale\Form\LocaleForm::export()
*/
function locale_translate_export_form($form, &$form_state) {
$languages = language_list();

View File

@ -182,21 +182,15 @@ function locale_menu() {
);
$items['admin/config/regional/translate/import'] = array(
'title' => '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;

View File

@ -40,6 +40,8 @@ function locale_translation_manual_status() {
* Page callback: Display the current translation status.
*
* @see locale_menu()
*
* @deprecated Use \Drupal\locale\Form\LocaleForm::status()
*/
function locale_translation_status_form($form, &$form_state) {
module_load_include('translation.inc', 'locale');

View File

@ -18,3 +18,27 @@ locale.translate_page:
_content: 'Drupal\locale\Controller\LocaleController::translatePage'
requirements:
_permission: 'translate interface'
locale.translate_import:
path: '/admin/config/regional/translate/import'
defaults:
_content: '\Drupal\locale\Form\LocaleForm::import'
_title: 'Import'
requirements:
_permission: 'translate interface'
locale.translate_export:
path: '/admin/config/regional/translate/export'
defaults:
_content: '\Drupal\locale\Form\LocaleForm::export'
_title: 'Export'
requirements:
_permission: 'translate interface'
locale.translate_status:
path: '/admin/reports/translations'
defaults:
_content: '\Drupal\locale\Form\LocaleForm::status'
_title: 'Available translation updates'
requirements:
_permission: 'translate interface'

View File

@ -2,7 +2,7 @@
/**
* @file
* Contains Drupal\shortcut\Access\LinkDeleteAccessCheck.
* Contains Drupal\shortcut\Access\LinkAccessCheck.
*/
namespace Drupal\shortcut\Access;
@ -14,13 +14,13 @@ use Symfony\Component\HttpFoundation\Request;
/**
* Provides an access check for shortcut link delete routes.
*/
class LinkDeleteAccessCheck implements StaticAccessCheckInterface {
class LinkAccessCheck implements StaticAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_access_shortcut_link_delete');
return array('_access_shortcut_link');
}
/**
@ -32,6 +32,7 @@ class LinkDeleteAccessCheck implements StaticAccessCheckInterface {
if ($shortcut_set = shortcut_set_load($set_name)) {
return shortcut_set_edit_access($shortcut_set) ? static::ALLOW : static::DENY;
}
return static::DENY;
}
}

View File

@ -0,0 +1,43 @@
<?php
/**
* @file
* Contains Drupal\shortcut\Access\ShortcutSetEditAccessCheck.
*/
namespace Drupal\shortcut\Access;
use Drupal\Core\Access\StaticAccessCheckInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides an access check for shortcut link delete routes.
*/
class ShortcutSetEditAccessCheck implements StaticAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_access_shortcut_set_edit');
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
$account = \Drupal::currentUser();
$shortcut_set = $request->attributes->get('shortcut_set');
// Sufficiently-privileged users can edit their currently displayed shortcut
// set, but not other sets. Shortcut administrators can edit any set.
if ($account->hasPermission('administer shortcuts')) {
return static::ALLOW;
}
if ($account->hasPermission('customize shortcut links')) {
return !isset($shortcut_set) || $shortcut_set == shortcut_current_displayed_set() ? static::ALLOW : static::DENY;
}
return static::DENY;
}
}

View File

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains Drupal\shortcut\Access\ShortcutSetSwitchAccessCheck.
*/
namespace Drupal\shortcut\Access;
use Drupal\Core\Access\StaticAccessCheckInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Provides an access check for shortcut link delete routes.
*/
class ShortcutSetSwitchAccessCheck implements StaticAccessCheckInterface {
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_access_shortcut_set_switch');
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
$user = \Drupal::currentUser();
$account = $request->attributes->get('account');
if ($user->hasPermission('administer shortcuts')) {
// Administrators can switch anyone's shortcut set.
return static::ALLOW;
}
if (!$user->hasPermission('switch shortcut sets')) {
// The user has no permission to switch anyone's shortcut set.
return static::DENY;
}
if (!isset($account) || $user->id() == $account->id()) {
// Users with the 'switch shortcut sets' permission can switch their own
// shortcuts sets.
return static::ALLOW;
}
return static::DENY;
}
}

View File

@ -0,0 +1,48 @@
<?php
/**
* @file
* Contains \Drupal\shortcut\Form\ShortcutForm.
*/
namespace Drupal\shortcut\Form;
use Drupal\menu_link\MenuLinkInterface;
use Drupal\shortcut\ShortcutSetInterface;
use Drupal\user\UserInterface;
/**
* Temporary form controller for shortcut module.
*/
class ShortcutForm {
/**
* Wraps shortcut_link_edit().
*
* @todo Remove shortcut_link_edit().
*/
public function edit(MenuLinkInterface $menu_link) {
module_load_include('admin.inc', 'shortcut');
return drupal_get_form('shortcut_link_edit', $menu_link);
}
/**
* Wraps shortcut_link_add().
*
* @todo Remove shortcut_link_add().
*/
public function add(ShortcutSetInterface $shortcut_set) {
module_load_include('admin.inc', 'shortcut');
return drupal_get_form('shortcut_link_add', $shortcut_set);
}
/**
* Wraps shortcut_set_switch().
*
* @todo Remove shortcut_set_switch().
*/
public function overview(UserInterface $user) {
module_load_include('admin.inc', 'shortcut');
return drupal_get_form('shortcut_set_switch', $user);
}
}

View File

@ -25,6 +25,8 @@ use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException;
* @ingroup forms
* @see shortcut_set_switch_validate()
* @see shortcut_set_switch_submit()
*
* @deprecated Use \Drupal\shortcut\Form\ShortcutForm::overview()
*/
function shortcut_set_switch($form, &$form_state, $account = NULL) {
$user = \Drupal::currentUser();
@ -188,6 +190,8 @@ function shortcut_set_switch_submit($form, &$form_state) {
* @ingroup forms
* @see shortcut_link_edit_validate()
* @see shortcut_link_add_submit()
*
* @deprecated Use \Drupal\shortcut\Form\ShortcutForm::add()
*/
function shortcut_link_add($form, &$form_state, $shortcut_set) {
drupal_set_title(t('Add new shortcut'));
@ -215,6 +219,8 @@ function shortcut_link_add($form, &$form_state, $shortcut_set) {
* @ingroup forms
* @see shortcut_link_edit_validate()
* @see shortcut_link_edit_submit()
*
* @deprecated Use \Drupal\shortcut\Form\ShortcutForm::edit()
*/
function shortcut_link_edit($form, &$form_state, $shortcut_link) {
drupal_set_title(t('Editing @shortcut', array('@shortcut' => $shortcut_link['link_title'])));

View File

@ -113,20 +113,12 @@ function shortcut_menu() {
);
$items['admin/config/user-interface/shortcut/manage/%shortcut_set/add-link'] = array(
'title' => '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.link_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.link_edit',
);
$items['admin/config/user-interface/shortcut/link/%menu_link/delete'] = array(
'title' => 'Delete shortcut',
@ -134,12 +126,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;

View File

@ -3,7 +3,7 @@ shortcut.link_delete:
defaults:
_form: 'Drupal\shortcut\Form\LinkDelete'
requirements:
_access_shortcut_link_delete: 'TRUE'
_access_shortcut_link: 'TRUE'
shortcut.set_delete:
path: '/admin/config/user-interface/shortcut/manage/{shortcut_set}/delete'
@ -47,3 +47,28 @@ shortcut.set_customize:
_entity_form: 'shortcut_set.customize'
requirements:
_entity_access: 'shortcut_set.update'
shortcut.link_add:
path: '/admin/config/user-interface/shortcut/manage/{shortcut_set}/add-link'
defaults:
_content: '\Drupal\shortcut\Form\ShortcutForm::add'
_title: 'Add Shortcut'
requirements:
_access_shortcut_set_edit: 'TRUE'
shortcut.link_edit:
path: '/admin/config/user-interface/shortcut/link/{menu_link}'
defaults:
_content: '\Drupal\shortcut\Form\ShortcutForm::edit'
_title: 'Add Shortcut'
requirements:
_access_shortcut_link: 'TRUE'
shortcut.overview:
path: 'user/{user}/shortcuts'
defaults:
_content: '\Drupal\shortcut\Form\ShortcutForm::overview'
_title: 'Shortcuts'
requirements:
_access_shortcut_set_switch: 'TRUE'

View File

@ -1,5 +1,15 @@
services:
access_check.shortcut.link:
class: Drupal\shortcut\Access\LinkDeleteAccessCheck
class: Drupal\shortcut\Access\LinkAccessCheck
tags:
- { name: access_check }
access_check.shortcut.shortcut_set_edit:
class: Drupal\shortcut\Access\ShortcutSetEditAccessCheck
tags:
- { name: access_check }
access_check.shortcut.shortcut_set_switch:
class: Drupal\shortcut\Access\ShortcutSetSwitchAccessCheck
tags:
- { name: access_check }

View File

@ -0,0 +1,24 @@
<?php
/**
* @file
* Contains \Drupal\system\Form\SystemForm.
*/
namespace Drupal\system\Form;
/**
* Temporary form controller for system module.
*/
class SystemForm {
/**
* Wraps system_date_format_localize_form().
*
* @todo Remove system_date_format_localize_form().
*/
public function localizeDateFormat($langcode) {
module_load_include('admin.inc', 'system');
return drupal_get_form('system_date_format_localize_form', $langcode);
}
}

View File

@ -734,6 +734,8 @@ function theme_system_themes_page($variables) {
* @see locale_menu()
* @see system_date_format_localize_form_submit()
* @ingroup forms
*
* @deprecated Use \Drupal\system\Form\SystemForm::localizeDateFormat()
*/
function system_date_format_localize_form($form, &$form_state, $langcode) {
// Display the current language name.

View File

@ -893,11 +893,8 @@ function system_menu() {
);
$items['admin/config/regional/date-time/locale/%/edit'] = array(
'title' => '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',

View File

@ -351,3 +351,11 @@ system.batch_page:
_controller: '\Drupal\system\Controller\BatchController::batchPage'
requirements:
_access: 'TRUE'
system.localize_date_format:
path: '/admin/config/regional/date-time/locale/{langcode}/edit'
defaults:
_content: '\Drupal\system\Form\SystemForm::localizeDateFormat'
_title: 'Localize date formats'
requirements:
_permission: 'administer site configuration'

View File

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains Drupal\update\Access\UpdateManagerAccessCheck.
*/
namespace Drupal\update\Access;
use Drupal\Component\Utility\Settings;
use Drupal\Core\Access\StaticAccessCheckInterface;
use Symfony\Component\Routing\Route;
use Symfony\Component\HttpFoundation\Request;
/**
* Determines whether allow authorized operations is set.
*/
class UpdateManagerAccessCheck implements StaticAccessCheckInterface {
/**
* Settings Service.
*
* @var \Drupal\Component\Utility\Settings
*/
protected $settings;
/**
* Constructs a UpdateManagerAccessCheck object.
*
* @param \Drupal\update\updateManager $update_manager
* update Manager Service.
*/
public function __construct(Settings $settings) {
$this->settings = $settings;
}
/**
* {@inheritdoc}
*/
public function appliesTo() {
return array('_access_update_manager');
}
/**
* {@inheritdoc}
*/
public function access(Route $route, Request $request) {
return $this->settings->get('allow_authorize_operations', TRUE) ? static::ALLOW : static::DENY;
}
}

View File

@ -0,0 +1,84 @@
<?php
/**
* @file
* Contains \Drupal\update\Form\UpdateForm.
*/
namespace Drupal\update\Form;
/**
* Temporary form controller for update module.
*/
class UpdateForm {
/**
* Wraps update_manager_install_form().
*
* @todo Remove update_manager_install_form().
*/
public function reportInstall() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_install_form', 'report');
}
/**
* Wraps update_manager_update_form().
*
* @todo Remove update_manager_update_form().
*/
public function reportUpdate() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_update_form', 'report');
}
/**
* Wraps update_manager_install_form().
*
* @todo Remove update_manager_install_form().
*/
public function moduleInstall() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_install_form', 'module');
}
/**
* Wraps update_manager_update_form().
*
* @todo Remove update_manager_update_form().
*/
public function moduleUpdate() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_update_form', 'module');
}
/**
* Wraps update_manager_install_form().
*
* @todo Remove update_manager_install_form().
*/
public function themeInstall() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_install_form', 'theme');
}
/**
* Wraps update_manager_update_form().
*
* @todo Remove update_manager_update_form().
*/
public function themeUpdate() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_update_form', 'theme');
}
/**
* Wraps update_manager_update_ready_form().
*
* @todo Remove update_manager_update_ready_form().
*/
public function confirmUpdates() {
module_load_include('manager.inc', 'update');
return drupal_get_form('update_manager_update_ready_form');
}
}

View File

@ -62,6 +62,10 @@ use Symfony\Component\HttpFoundation\RedirectResponse;
* @see update_manager_update_form_submit()
* @see update_menu()
* @ingroup forms
*
* @deprecated Use \Drupal\update\Form\UpdateForm::reportUpdate(),
* \Drupal\update\Form\UpdateForm::moduleUpdate(), or
* \Drupal\update\Form\UpdateForm::moduleUpdate()
*/
function update_manager_update_form($form, $form_state = array(), $context) {
if (!_update_manager_check_backends($form, 'update')) {
@ -507,6 +511,10 @@ function update_manager_update_ready_form_submit($form, &$form_state) {
* @see update_manager_install_form_submit()
* @see update_menu()
* @ingroup forms
*
* @deprecated Use \Drupal\update\Form\UpdateForm::reportInstall(),
* \Drupal\update\Form\UpdateForm::moduleInstall(), or
* \Drupal\update\Form\UpdateForm::moduleInstall()
*/
function update_manager_install_form($form, &$form_state, $context) {
if (!_update_manager_check_backends($form, 'install')) {

View File

@ -187,23 +187,15 @@ function update_menu() {
);
foreach ($paths as $context => $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.
@ -212,18 +204,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;
}

View File

@ -19,3 +19,77 @@ update.manual_status:
_content: '\Drupal\update\Controller\UpdateController::updateStatusManually'
requirements:
_permission: 'administer site configuration'
update.report_install:
path: '/admin/reports/updates/install'
defaults:
_content: '\Drupal\update\Form\UpdateForm::reportInstall'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.report_update:
path: '/admin/reports/updates/update'
defaults:
_content: '\Drupal\update\Form\UpdateForm::reportUpdate'
_title: 'Update'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.module_install:
path: '/admin/modules/install'
defaults:
_content: '\Drupal\update\Form\UpdateForm::moduleInstall'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.module_update:
path: '/admin/modules/update'
defaults:
_content: '\Drupal\update\Form\UpdateForm::moduleUpdate'
_title: 'Update'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.theme_install:
path: '/admin/theme/install'
defaults:
_content: '\Drupal\update\Form\UpdateForm::themeInstall'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.theme_update:
path: '/admin/theme/update'
defaults:
_content: '\Drupal\update\Form\UpdateForm::themeUpdate'
_title: 'Update'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'
update.confirmation_page:
path: '/admin/update/ready'
defaults:
_content: '\Drupal\update\Form\UpdateForm::confirmUpdates'
_title: 'Ready to update'
options:
_access_mode: 'ALL'
requirements:
_permission: 'administer software updates'
_access_update_manager: 'TRUE'

View File

@ -0,0 +1,6 @@
services:
access_check.update.manager_access:
class: Drupal\update\Access\UpdateManagerAccessCheck
arguments: ['@settings']
tags:
- { name: access_check }

View File

@ -0,0 +1,24 @@
<?php
/**
* @file
* Contains \Drupal\user\Form\UserForm.
*/
namespace Drupal\user\Form;
/**
* Temporary form controller for user module.
*/
class UserForm {
/**
* Wraps user_pass_reset().
*
* @todo Remove user_pass_reset().
*/
public function resetPass($uid, $timestamp, $hash, $operation) {
module_load_include('pages.inc', 'user');
return drupal_get_form('user_pass_reset', $uid, $timestamp, $hash, $operation);
}
}

View File

@ -759,13 +759,12 @@ function user_menu() {
'route_name' => 'user.pass',
'type' => MENU_LOCAL_TASK,
);
// Since menu_get_ancestors() does not support multiple placeholders in a row,
// this MENU_CALLBACK cannot be removed yet.
$items['user/reset/%/%/%'] = array(
'title' => 'Reset password',
'page callback' => 'drupal_get_form',
'page arguments' => array('user_pass_reset', 2, 3, 4),
'access callback' => TRUE,
'route_name' => 'user.reset',
'type' => MENU_CALLBACK,
'file' => 'user.pages.inc',
);
$items['user/logout'] = array(

View File

@ -13,6 +13,8 @@ use Drupal\Component\Utility\Crypt;
/**
* Menu callback; process one time login link and redirects to the user page on success.
*
* @deprecated Use \Drupal\user\Form\UserForm::resetPass()
*/
function user_pass_reset($form, &$form_state, $uid, $timestamp, $hashed_pass, $action = NULL) {
global $user;

View File

@ -150,3 +150,12 @@ user.cancel_confirm:
hashed_pass: ''
requirements:
_entity_access: 'user.delete'
user.reset:
path: '/user/reset/{uid}/{timestamp}/{hash}/{operation}'
defaults:
_content: '\Drupal\user\Form\UserForm::resetPass'
_title: 'Reset password'
operation: NULL
requirements:
_access: 'TRUE'