Commit ccd257a9 authored by webchick's avatar webchick

Issue #2063401 by dawehner, damiankloip, tim.plunkett: Replace the default...

Issue #2063401 by dawehner, damiankloip, tim.plunkett: Replace the default _access_checks()(access mode) with ALL instead of ANY.
parent 34eb47b5
...@@ -227,7 +227,7 @@ public function checkNamedRoute($route_name, array $parameters = array(), Reques ...@@ -227,7 +227,7 @@ public function checkNamedRoute($route_name, array $parameters = array(), Reques
public function check(Route $route, Request $request) { public function check(Route $route, Request $request) {
$checks = $route->getOption('_access_checks') ?: array(); $checks = $route->getOption('_access_checks') ?: array();
$conjunction = $route->getOption('_access_mode') ?: 'ANY'; $conjunction = $route->getOption('_access_mode') ?: 'ALL';
if ($conjunction == 'ALL') { if ($conjunction == 'ALL') {
return $this->checkAll($checks, $route, $request); return $this->checkAll($checks, $route, $request);
......
...@@ -2,8 +2,6 @@ block.admin_demo: ...@@ -2,8 +2,6 @@ block.admin_demo:
path: '/admin/structure/block/demo/{theme}' path: '/admin/structure/block/demo/{theme}'
defaults: defaults:
_content: '\Drupal\block\Controller\BlockController::demo' _content: '\Drupal\block\Controller\BlockController::demo'
options:
_access_mode: 'ALL'
requirements: requirements:
_access_theme: 'TRUE' _access_theme: 'TRUE'
_permission: 'administer blocks' _permission: 'administer blocks'
......
...@@ -48,9 +48,6 @@ public function routes(RouteBuildEvent $event) { ...@@ -48,9 +48,6 @@ public function routes(RouteBuildEvent $event) {
array( array(
'_access_theme' => 'TRUE', '_access_theme' => 'TRUE',
'_permission' => 'administer blocks', '_permission' => 'administer blocks',
),
array(
'_access_mode' => 'ALL',
) )
); );
$collection->add("block.admin_display_$key", $route); $collection->add("block.admin_display_$key", $route);
......
...@@ -67,12 +67,6 @@ function setUp() { ...@@ -67,12 +67,6 @@ function setUp() {
'footer', 'footer',
); );
$default_theme = variable_get('theme_default', 'stark');
$manager = $this->container->get('plugin.manager.block');
$instances = config_get_storage_names_with_prefix('plugin.core.block.' . $default_theme);
foreach ($instances as $plugin_id) {
\Drupal::config($plugin_id)->delete();
}
} }
/** /**
......
...@@ -23,8 +23,6 @@ book.export: ...@@ -23,8 +23,6 @@ book.export:
path: '/book/export/{type}/{node}' path: '/book/export/{type}/{node}'
defaults: defaults:
_controller: '\Drupal\book\Controller\BookController::bookExport' _controller: '\Drupal\book\Controller\BookController::bookExport'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'access printer-friendly version' _permission: 'access printer-friendly version'
_entity_access: 'node.view' _entity_access: 'node.view'
...@@ -33,8 +31,6 @@ book.outline: ...@@ -33,8 +31,6 @@ book.outline:
path: '/node/{node}/outline' path: '/node/{node}/outline'
defaults: defaults:
_entity_form: 'node.book_outline' _entity_form: 'node.book_outline'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'administer book outlines' _permission: 'administer book outlines'
_entity_access: 'node.view' _entity_access: 'node.view'
...@@ -44,8 +40,6 @@ book.admin_edit: ...@@ -44,8 +40,6 @@ book.admin_edit:
defaults: defaults:
_form: 'Drupal\book\Form\BookAdminEditForm' _form: 'Drupal\book\Form\BookAdminEditForm'
_title: 'Re-order book pages and change titles' _title: 'Re-order book pages and change titles'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'administer book outlines' _permission: 'administer book outlines'
_entity_access: 'node.view' _entity_access: 'node.view'
......
...@@ -63,6 +63,7 @@ public function routes(RouteBuildEvent $event) { ...@@ -63,6 +63,7 @@ public function routes(RouteBuildEvent $event) {
'_permission' => 'translate any entity', '_permission' => 'translate any entity',
), ),
array( array(
'_access_mode' => 'ANY',
'parameters' => array( 'parameters' => array(
'entity' => array( 'entity' => array(
'type' => 'entity:' . $entity_type, 'type' => 'entity:' . $entity_type,
...@@ -86,6 +87,7 @@ public function routes(RouteBuildEvent $event) { ...@@ -86,6 +87,7 @@ public function routes(RouteBuildEvent $event) {
'_access_content_translation_manage' => 'create', '_access_content_translation_manage' => 'create',
), ),
array( array(
'_access_mode' => 'ANY',
'parameters' => array( 'parameters' => array(
'entity' => array( 'entity' => array(
'type' => 'entity:' . $entity_type, 'type' => 'entity:' . $entity_type,
...@@ -107,6 +109,7 @@ public function routes(RouteBuildEvent $event) { ...@@ -107,6 +109,7 @@ public function routes(RouteBuildEvent $event) {
'_access_content_translation_manage' => 'update', '_access_content_translation_manage' => 'update',
), ),
array( array(
'_access_mode' => 'ANY',
'parameters' => array( 'parameters' => array(
'entity' => array( 'entity' => array(
'type' => 'entity:' . $entity_type, 'type' => 'entity:' . $entity_type,
...@@ -133,6 +136,7 @@ public function routes(RouteBuildEvent $event) { ...@@ -133,6 +136,7 @@ public function routes(RouteBuildEvent $event) {
'type' => 'entity:' . $entity_type, 'type' => 'entity:' . $entity_type,
), ),
), ),
'_access_mode' => 'ANY',
) )
); );
$collection->add("content_translation.delete_$entity_type", $route); $collection->add("content_translation.delete_$entity_type", $route);
......
...@@ -16,8 +16,6 @@ edit.field_form: ...@@ -16,8 +16,6 @@ edit.field_form:
path: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}' path: '/edit/form/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
defaults: defaults:
_controller: '\Drupal\edit\EditController::fieldForm' _controller: '\Drupal\edit\EditController::fieldForm'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'access in-place editing' _permission: 'access in-place editing'
_access_edit_entity_field: 'TRUE' _access_edit_entity_field: 'TRUE'
...@@ -26,8 +24,6 @@ edit.entity_save: ...@@ -26,8 +24,6 @@ edit.entity_save:
path: '/edit/entity/{entity_type}/{entity}' path: '/edit/entity/{entity_type}/{entity}'
defaults: defaults:
_controller: '\Drupal\edit\EditController::entitySave' _controller: '\Drupal\edit\EditController::entitySave'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'access in-place editing' _permission: 'access in-place editing'
_access_edit_entity: 'TRUE' _access_edit_entity: 'TRUE'
...@@ -2,8 +2,6 @@ editor.field_untransformed_text: ...@@ -2,8 +2,6 @@ editor.field_untransformed_text:
path: '/editor/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}' path: '/editor/{entity_type}/{entity}/{field_name}/{langcode}/{view_mode_id}'
defaults: defaults:
_controller: '\Drupal\editor\EditorController::getUntransformedText' _controller: '\Drupal\editor\EditorController::getUntransformedText'
options:
_access_mode: 'ALL'
requirements: requirements:
_permission: 'access in-place editing' _permission: 'access in-place editing'
_access_edit_entity_field: 'TRUE' _access_edit_entity_field: 'TRUE'
......
...@@ -39,8 +39,6 @@ filter.admin_disable: ...@@ -39,8 +39,6 @@ filter.admin_disable:
path: '/admin/config/content/formats/manage/{filter_format}/disable' path: '/admin/config/content/formats/manage/{filter_format}/disable'
defaults: defaults:
_entity_form: 'filter_format.disable' _entity_form: 'filter_format.disable'
options:
_access_mode: 'ALL'
requirements: requirements:
_filter_disable_format_access: 'TRUE' _filter_disable_format_access: 'TRUE'
_permission: 'administer filters' _permission: 'administer filters'
...@@ -25,6 +25,8 @@ node.add_page: ...@@ -25,6 +25,8 @@ node.add_page:
defaults: defaults:
_title: 'Add page' _title: 'Add page'
_content: '\Drupal\node\Controller\NodeController::addPage' _content: '\Drupal\node\Controller\NodeController::addPage'
options:
_access_mode: 'ANY'
requirements: requirements:
_permission: 'administer content types' _permission: 'administer content types'
_node_add_access: 'node' _node_add_access: 'node'
......
...@@ -92,6 +92,8 @@ public function routes() { ...@@ -92,6 +92,8 @@ public function routes() {
// The HTTP method is a requirement for this route. // The HTTP method is a requirement for this route.
'_method' => $method, '_method' => $method,
'_permission' => "restful $lower_method $this->pluginId", '_permission' => "restful $lower_method $this->pluginId",
), array(
'_access_mode' => 'ANY',
)); ));
switch ($method) { switch ($method) {
......
...@@ -64,10 +64,7 @@ public function routes(RouteBuildEvent $event) { ...@@ -64,10 +64,7 @@ public function routes(RouteBuildEvent $event) {
'_search_plugin_view_access' => $plugin_id, '_search_plugin_view_access' => $plugin_id,
'_permission' => 'search content', '_permission' => 'search content',
); );
$options = array( $route = new Route($path, $defaults, $requirements);
'_access_mode' => 'ALL',
);
$route = new Route($path, $defaults, $requirements, $options);
$collection->add('search.view_' . $plugin_id, $route); $collection->add('search.view_' . $plugin_id, $route);
} }
} }
......
...@@ -19,8 +19,6 @@ search.view: ...@@ -19,8 +19,6 @@ search.view:
_content: '\Drupal\search\Controller\SearchController::searchView' _content: '\Drupal\search\Controller\SearchController::searchView'
plugin_id: NULL plugin_id: NULL
keys: '' keys: ''
options:
_access_mode: 'ALL'
requirements: requirements:
keys: '.+' keys: '.+'
_permission: 'search content' _permission: 'search content'
......
...@@ -182,6 +182,13 @@ public function providerTestCheckConjunctions() { ...@@ -182,6 +182,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::KILL, 'condition_two' => AccessCheckInterface::KILL,
'expected' => FALSE, 'expected' => FALSE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_4',
'condition_one' => AccessCheckInterface::ALLOW,
'condition_two' => AccessCheckInterface::KILL,
'expected' => FALSE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ALL', 'conjunction' => 'ALL',
'name' => 'test_route_5', 'name' => 'test_route_5',
...@@ -189,6 +196,13 @@ public function providerTestCheckConjunctions() { ...@@ -189,6 +196,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::DENY, 'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE, 'expected' => FALSE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_5',
'condition_one' => AccessCheckInterface::ALLOW,
'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ALL', 'conjunction' => 'ALL',
'name' => 'test_route_6', 'name' => 'test_route_6',
...@@ -196,6 +210,13 @@ public function providerTestCheckConjunctions() { ...@@ -196,6 +210,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::DENY, 'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE, 'expected' => FALSE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_6',
'condition_one' => AccessCheckInterface::KILL,
'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ALL', 'conjunction' => 'ALL',
'name' => 'test_route_7', 'name' => 'test_route_7',
...@@ -203,6 +224,13 @@ public function providerTestCheckConjunctions() { ...@@ -203,6 +224,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::ALLOW, 'condition_two' => AccessCheckInterface::ALLOW,
'expected' => TRUE, 'expected' => TRUE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_7',
'condition_one' => AccessCheckInterface::ALLOW,
'condition_two' => AccessCheckInterface::ALLOW,
'expected' => TRUE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ALL', 'conjunction' => 'ALL',
'name' => 'test_route_8', 'name' => 'test_route_8',
...@@ -210,6 +238,13 @@ public function providerTestCheckConjunctions() { ...@@ -210,6 +238,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::KILL, 'condition_two' => AccessCheckInterface::KILL,
'expected' => FALSE, 'expected' => FALSE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_8',
'condition_one' => AccessCheckInterface::KILL,
'condition_two' => AccessCheckInterface::KILL,
'expected' => FALSE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ALL', 'conjunction' => 'ALL',
'name' => 'test_route_9', 'name' => 'test_route_9',
...@@ -217,6 +252,13 @@ public function providerTestCheckConjunctions() { ...@@ -217,6 +252,13 @@ public function providerTestCheckConjunctions() {
'condition_two' => AccessCheckInterface::DENY, 'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE, 'expected' => FALSE,
); );
$access_configurations[] = array(
'conjunction' => NULL,
'name' => 'test_route_9',
'condition_one' => AccessCheckInterface::DENY,
'condition_two' => AccessCheckInterface::DENY,
'expected' => FALSE,
);
$access_configurations[] = array( $access_configurations[] = array(
'conjunction' => 'ANY', 'conjunction' => 'ANY',
'name' => 'test_route_10', 'name' => 'test_route_10',
...@@ -282,7 +324,7 @@ public function testCheckConjunctions($conjunction, $name, $condition_one, $cond ...@@ -282,7 +324,7 @@ public function testCheckConjunctions($conjunction, $name, $condition_one, $cond
'_access' => static::convertAccessCheckInterfaceToString($condition_one), '_access' => static::convertAccessCheckInterfaceToString($condition_one),
'_test_access' => static::convertAccessCheckInterfaceToString($condition_two), '_test_access' => static::convertAccessCheckInterfaceToString($condition_two),
); );
$options = array('_access_mode' => $conjunction); $options = $conjunction ? array('_access_mode' => $conjunction) : array();
$route = new Route($name, array(), $requirements, $options); $route = new Route($name, array(), $requirements, $options);
$route_collection->add($name, $route); $route_collection->add($name, $route);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment