1: <?php
2:
3: namespace Mapbender\DrupalIntegrationBundle\Security\Authorization\Voter;
4:
5: use Symfony\Component\DependencyInjection\ContainerInterface;
6: use Symfony\Component\Security\Core\Authorization\Voter\VoterInterface;
7: use Symfony\Component\Security\Core\Authentication\Token\TokenInterface;
8:
9: 10: 11: 12: 13: 14: 15:
16: class Uid1Voter implements VoterInterface
17: {
18: public function __construct(ContainerInterface $container)
19: {
20: $this->container = $container;
21: }
22:
23: public function supportsAttribute($attribute)
24: {
25: return true;
26: }
27:
28: public function supportsClass($class)
29: {
30: return true;
31: }
32:
33: function vote(TokenInterface $token, $object, array $attributes)
34: {
35: $user = $token->getUser();
36:
37: if(is_object($user) && get_class($user) === 'Mapbender\DrupalIntegrationBundle\Security\User\DrupalUser' && $user->getId() == 1) {
38: return VoterInterface::ACCESS_GRANTED;
39: }
40:
41: return VoterInterface::ACCESS_ABSTAIN;
42: }
43: }
44: