Change wording from object to subject

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
This commit is contained in:
Grégoire Paris 2017-06-15 18:40:16 +02:00
parent b23ddfefce
commit d261894c6e
No known key found for this signature in database
GPG Key ID: F30226DD290FCB25
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);
}