minor #23201 Change wording from object to subject (greg0ire)

This PR was merged into the 3.4 branch.

Discussion
----------

Change wording from object to subject

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | no
| New feature?  | no <!-- don't forget updating src/**/CHANGELOG.md files -->
| BC breaks?    | no
| Deprecations? | no <!-- don't forget updating UPGRADE-*.md files -->
| Tests pass?   | yes
| License       | MIT

The authorization checker has been changed to support any value
recently. The naming should reflect that to avoid confusion.
Refs https://github.com/sonata-project/SonataAdminBundle/issues/4518

Commits
-------

d261894c6e Change wording from object to subject
This commit is contained in:
Fabien Potencier 2017-07-03 11:28:26 +03:00
commit f9173ea511
3 changed files with 14 additions and 14 deletions

View File

@ -159,40 +159,40 @@ trait ControllerTrait
}
/**
* Checks if the attributes are granted against the current authentication token and optionally supplied object.
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
*
* @param mixed $attributes The attributes
* @param mixed $object The object
* @param mixed $subject The subject
*
* @return bool
*
* @throws \LogicException
*/
protected function isGranted($attributes, $object = null)
protected function isGranted($attributes, $subject = null)
{
if (!$this->container->has('security.authorization_checker')) {
throw new \LogicException('The SecurityBundle is not registered in your application.');
}
return $this->container->get('security.authorization_checker')->isGranted($attributes, $object);
return $this->container->get('security.authorization_checker')->isGranted($attributes, $subject);
}
/**
* Throws an exception unless the attributes are granted against the current authentication token and optionally
* supplied object.
* supplied subject.
*
* @param mixed $attributes The attributes
* @param mixed $object The object
* @param mixed $subject The subject
* @param string $message The message passed to the exception
*
* @throws AccessDeniedException
*/
protected function denyAccessUnlessGranted($attributes, $object = null, $message = 'Access Denied.')
protected function denyAccessUnlessGranted($attributes, $subject = null, $message = 'Access Denied.')
{
if (!$this->isGranted($attributes, $object)) {
if (!$this->isGranted($attributes, $subject)) {
$exception = $this->createAccessDeniedException($message);
$exception->setAttributes($attributes);
$exception->setSubject($object);
$exception->setSubject($subject);
throw $exception;
}

View File

@ -51,7 +51,7 @@ class AuthorizationChecker implements AuthorizationCheckerInterface
*
* @throws AuthenticationCredentialsNotFoundException when the token storage has no authentication token.
*/
final public function isGranted($attributes, $object = null)
final public function isGranted($attributes, $subject = null)
{
if (null === ($token = $this->tokenStorage->getToken())) {
throw new AuthenticationCredentialsNotFoundException('The token storage contains no authentication token. One possible reason may be that there is no firewall configured for this URL.');
@ -65,6 +65,6 @@ class AuthorizationChecker implements AuthorizationCheckerInterface
$attributes = array($attributes);
}
return $this->accessDecisionManager->decide($token, $attributes, $object);
return $this->accessDecisionManager->decide($token, $attributes, $subject);
}
}

View File

@ -19,12 +19,12 @@ namespace Symfony\Component\Security\Core\Authorization;
interface AuthorizationCheckerInterface
{
/**
* Checks if the attributes are granted against the current authentication token and optionally supplied object.
* Checks if the attributes are granted against the current authentication token and optionally supplied subject.
*
* @param mixed $attributes
* @param mixed $object
* @param mixed $subject
*
* @return bool
*/
public function isGranted($attributes, $object = null);
public function isGranted($attributes, $subject = null);
}