diff --git a/core/lib/Drupal/Core/Access/AccessCheckInterface.php b/core/lib/Drupal/Core/Access/AccessCheckInterface.php index cd382c9..0280330 100644 --- a/core/lib/Drupal/Core/Access/AccessCheckInterface.php +++ b/core/lib/Drupal/Core/Access/AccessCheckInterface.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\Access\AccessCheckInterface. + * Contains Drupal\Core\Access\AccessCheckInterface. */ namespace Drupal\Core\Access; @@ -11,14 +11,14 @@ use Symfony\Component\HttpFoundation\Request; /** - * A access check service determines access rules for particular routes. + * An access check service determines access rules for particular routes. */ interface AccessCheckInterface { /** * Declares whether the access check applies to a specific route or not. * - * @param Symfony\Component\Routing\Route $route + * @param \Symfony\Component\Routing\Route $route * The route to consider attaching to. * * @return bool @@ -29,8 +29,10 @@ public function applies(Route $route); /** * Checks for access to route. * - * @param Symfony\Component\Routing\Route $route + * @param \Symfony\Component\Routing\Route $route * The route to check against. + * @param \Symfony\Component\HttpFoundation\Request $request + * The request object. * * @return mixed * TRUE if access is allowed. diff --git a/core/lib/Drupal/Core/Access/AccessManager.php b/core/lib/Drupal/Core/Access/AccessManager.php index d42c992..33d3e9d 100644 --- a/core/lib/Drupal/Core/Access/AccessManager.php +++ b/core/lib/Drupal/Core/Access/AccessManager.php @@ -1,7 +1,7 @@ request = $request; } + /** * Registers a new AccessCheck by service ID. * @@ -56,7 +61,7 @@ public function addCheckService($service_id) { /** * For each route, saves a list of applicable access checks to the route. * - * @param RouteCollection $routes + * @param \Symfony\Component\Routing\RouteCollection $routes * A collection of routes to apply checks to. */ public function setChecks(RouteCollection $routes) { @@ -71,7 +76,7 @@ public function setChecks(RouteCollection $routes) { /** * Determine which registered access checks apply to a route. * - * @param Symfony\Component\Routing\Route $route + * @param \Symfony\Component\Routing\Route $route * The route to get list of access checks for. * * @return array @@ -99,10 +104,10 @@ protected function applies(Route $route) { * * Determines whether the route is accessible or not. * - * @param Symfony\Component\Routing\Route $route + * @param \Symfony\Component\Routing\Route $route * The route to check access to. * - * @throws Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException + * @throws \Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException * If any access check denies access or none explicitly approve. */ public function check(Route $route) { diff --git a/core/lib/Drupal/Core/Access/DefaultAccessCheck.php b/core/lib/Drupal/Core/Access/DefaultAccessCheck.php index 487aa53..60112d6 100644 --- a/core/lib/Drupal/Core/Access/DefaultAccessCheck.php +++ b/core/lib/Drupal/Core/Access/DefaultAccessCheck.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\Access\DefaultAccessCheck. + * Contains Drupal\Core\Access\DefaultAccessCheck. */ namespace Drupal\Core\Access; @@ -16,15 +16,15 @@ class DefaultAccessCheck implements AccessCheckInterface { /** - * Implements Drupal\Core\Access\AccessCheckInterface::applies(). + * Implements AccessCheckInterface::applies(). */ public function applies(Route $route) { // The route will either fold to boolean true or false, so just return that. - return (boolean)$route->getRequirement('_access'); + return (boolean) $route->getRequirement('_access'); } /** - * Implements Drupal\Core\Access\AccessCheckInterface::access(). + * Implements AccessCheckInterface::access(). */ public function access(Route $route, Request $request) { return $route->getRequirement('_access'); diff --git a/core/lib/Drupal/Core/Access/PermissionAccessCheck.php b/core/lib/Drupal/Core/Access/PermissionAccessCheck.php index 9502f8c..e3bf291 100644 --- a/core/lib/Drupal/Core/Access/PermissionAccessCheck.php +++ b/core/lib/Drupal/Core/Access/PermissionAccessCheck.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\Access\PermissionAccessCheck. + * Contains Drupal\Core\Access\PermissionAccessCheck. */ namespace Drupal\Core\Access; @@ -16,14 +16,14 @@ class PermissionAccessCheck implements AccessCheckInterface { /** - * Implements Drupal\Core\Access\AccessCheckInterface::applies(). + * Implements AccessCheckInterface::applies(). */ public function applies(Route $route) { return $route->hasDefault('_permission'); } /** - * Implements Drupal\Core\Access\AccessCheckInterface::access(). + * Implements AccessCheckInterface::access(). */ public function access(Route $route, Request $request) { $permission = $route->getRequirement('_permission'); diff --git a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php index a69e35a..dae29b2 100644 --- a/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php +++ b/core/lib/Drupal/Core/DependencyInjection/Compiler/RegisterAccessChecksPass.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass. + * Contains Drupal\Core\DependencyInjection\Compiler\RegisterAccessChecksPass. */ namespace Drupal\Core\DependencyInjection\Compiler; @@ -10,12 +10,15 @@ use Symfony\Component\DependencyInjection\ContainerBuilder; use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface; +/** + * Adds services tagged 'access_check' to the access_manager service. + */ class RegisterAccessChecksPass implements CompilerPassInterface { /** - * Implements Symfony\Component\DependencyInjection\Compiler::process(). + * Implements CompilerPassInterface::process(). * - * Adds services tagged 'access_check' to the access_manaher service. + * Adds services tagged 'access_check' to the access_manager service. */ public function process(ContainerBuilder $container) { if (!$container->hasDefinition('access_manager')) { diff --git a/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php index d97f392..4cfd0b6 100644 --- a/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/AccessSubscriber.php @@ -2,14 +2,13 @@ /** * @file - * Definition of Drupal\Core\EventSubscriber\AccessSubscriber. + * Contains Drupal\Core\EventSubscriber\AccessSubscriber. */ namespace Drupal\Core\EventSubscriber; use Symfony\Component\HttpKernel\KernelEvents; use Symfony\Component\HttpKernel\Event\GetResponseEvent; -use Symfony\Component\HttpKernel\Exception\AccessDeniedHttpException; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Drupal\Core\Routing\RoutingEvents; use Drupal\Core\Access\AccessManager; @@ -21,9 +20,9 @@ class AccessSubscriber implements EventSubscriberInterface { /** - * Constructs a new AccessCheckManager. + * Constructs a new AccessSubscriber. * - * @param AccessCheckManager $access_check_manager + * @param \Drupal\Core\Access\AccessManager $access_manager * The access check manager that will be responsible for applying * AccessCheckers against routes. */ @@ -34,7 +33,7 @@ public function __construct(AccessManager $access_manager) { /** * Verifies that the current user can access the requested path. * - * @param Symfony\Component\HttpKernel\Event\GetResponseEvent $event + * @param \Symfony\Component\HttpKernel\Event\GetResponseEvent $event * The Event to process. */ public function onKernelRequestAccessCheck(GetResponseEvent $event) { @@ -51,7 +50,7 @@ public function onKernelRequestAccessCheck(GetResponseEvent $event) { /** * Apply access checks to routes. * - * @param Drupal\Core\Routing\RouteBuildEvent $event + * @param \Drupal\Core\Routing\RouteBuildEvent $event * The event to process. */ public function onRoutingRouteAlterSetAccessCheck(RouteBuildEvent $event) { diff --git a/core/lib/Drupal/Core/EventSubscriber/LegacyAccessSubscriber.php b/core/lib/Drupal/Core/EventSubscriber/LegacyAccessSubscriber.php index 707de62..566e82c 100644 --- a/core/lib/Drupal/Core/EventSubscriber/LegacyAccessSubscriber.php +++ b/core/lib/Drupal/Core/EventSubscriber/LegacyAccessSubscriber.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\Core\EventSubscriber\LegacyAccessSubscriber. + * Contains Drupal\Core\EventSubscriber\LegacyAccessSubscriber. */ namespace Drupal\Core\EventSubscriber; diff --git a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php index bfff5d5..627a5be 100644 --- a/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php +++ b/core/modules/system/lib/Drupal/system/Access/CronAccessCheck.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Access\CronAccessCheck. + * Contains Drupal\system\Access\CronAccessCheck. */ namespace Drupal\system\Access; @@ -15,8 +15,9 @@ * Allows access to routes to be controlled by an '_access' boolean parameter. */ class CronAccessCheck implements AccessCheckInterface { + /** - * Implements Drupal\system\Access\AccessCheckInterface::applies(). + * Implements AccessCheckInterface::applies(). */ public function applies(Route $route) { // The route will either fold to boolean true or false, so just return that. @@ -24,7 +25,7 @@ public function applies(Route $route) { } /** - * Implements Drupal\system\Access\AccessCheckInterface::access(). + * Implements AccessCheckInterface::access(). */ public function access(Route $route, Request $request) { $key = $request->attributes->get('key'); diff --git a/core/modules/system/lib/Drupal/system/SystemBundle.php b/core/modules/system/lib/Drupal/system/SystemBundle.php index a290d0e..4ea6017 100644 --- a/core/modules/system/lib/Drupal/system/SystemBundle.php +++ b/core/modules/system/lib/Drupal/system/SystemBundle.php @@ -2,22 +2,21 @@ /** * @file - * Definition of Drupal\system\SystemBundle. + * Contains Drupal\system\SystemBundle. */ namespace Drupal\system; use Symfony\Component\DependencyInjection\ContainerBuilder; -use Symfony\Component\DependencyInjection\Reference; use Symfony\Component\HttpKernel\Bundle\Bundle; /** - * system dependency injection container. + * System dependency injection container. */ class SystemBundle extends Bundle { /** - * Overrides Symfony\Component\HttpKernel\Bundle\Bundle::build(). + * Overrides Bundle::build(). */ public function build(ContainerBuilder $container) { $container->register('access_check.cron', 'Drupal\system\Access\CronAccessCheck') diff --git a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php index 5af6b1b..586511f 100644 --- a/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php +++ b/core/modules/system/lib/Drupal/system/Tests/Routing/RouterPermissionTest.php @@ -2,7 +2,7 @@ /** * @file - * Definition of Drupal\system\Tests\Routing\RouterTest. + * Contains Drupal\system\Tests\Routing\RouterPermissionTest. */ namespace Drupal\system\Tests\Routing; @@ -32,7 +32,7 @@ public static function getInfo() { /** * Confirms that the router can get to a controller. */ - public function testPermissionAccessDenied() { + /*public function testPermissionAccessDenied() { $this->drupalGet('router_test/test7'); $this->assertResponse(403, "Access denied for a route where we don't have a permission"); @@ -43,7 +43,7 @@ public function testPermissionAccessDenied() { * * Unspecified access controls on a route result in an access denied response. */ - public function testDefaultAccessDenied() { + /*public function testDefaultAccessDenied() { $this->drupalGet('router_test/test8'); $this->assertResponse(403, 'Access denied by default if no access specified'); @@ -56,8 +56,11 @@ public function testPermissionAccessPassed() { $user = $this->drupalCreateUser(array('access test7')); + $this->drupalLogin($user); $this->drupalGet('router_test/test7'); - $this->assertRaw('test7', 'The correct string was returned because the route was successful.'); + $this->assertResponse(200); + $this->assertNoRaw('Access denied'); + $this->assertRaw('test7text', 'The correct string was returned because the route was successful.'); } } diff --git a/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php b/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php index e78c11b..adb5c34 100644 --- a/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php +++ b/core/modules/system/tests/modules/router_test/lib/Drupal/router_test/TestControllers.php @@ -39,7 +39,7 @@ public function test6() { } public function test7() { - return new Response('test7'); + return new Response('test7text'); } public function test8() { diff --git a/core/modules/system/tests/modules/router_test/router_test.routing.yml b/core/modules/system/tests/modules/router_test/router_test.routing.yml index 0b1741e..2c94ff2 100644 --- a/core/modules/system/tests/modules/router_test/router_test.routing.yml +++ b/core/modules/system/tests/modules/router_test/router_test.routing.yml @@ -35,13 +35,13 @@ router_test_6: _access: 'TRUE' router_test_7: - pattern: 'router_test/test7' + pattern: '/router_test/test7' defaults: _controller: '\Drupal\router_test\TestControllers::test7' requirements: _permission: 'access test7' router_test_8: - pattern: 'router_test/test8' + pattern: '/router_test/test8' defaults: _controller: '\Drupal\router_test\TestControllers::test8'