src/Acl/Serializer/Normalizer/Property/AbstractNormalizer.php
public function denormalize($data, $class, $format = null, array $context = [])
    {
        if ($this->entityCollection->contains($class)) {
            $token = $this->tokenStorage->getToken();

            if (!$token) {
                throw new LogicException('Token is not defined.');
            }

            $attribute = Permission::EDIT;
            $subject = [
                0 => null,
                1 => null
            ];

            if (array_key_exists('object_to_populate', $context)) {
                $subject[0] = $context['object_to_populate'];
            } else {
                $object = new $context['resource_class'];

                foreach ($data as $property => $value) {
                    if (in_array($property, ['uuid', 'owner', 'ownerUuid', 'identity', 'identityUuid'], true)) {
                        // Set the required values for permission scope voters to vote on.
                        $object->{'set'.$property}($value);
                    }
                }

                $subject[0] = $object;
            }

            foreach (array_keys($data) as $property) {
                $subject[1] = $property;
                $vote = $this->voter->vote($token, $subject, [$attribute]);

                if (VoterInterface::ACCESS_ABSTAIN === $vote) {
                    throw new LogicException('Voter cannot abstain from voting.');
                }

                if (VoterInterface::ACCESS_DENIED === $vote) {
                    unset($data[$property]);
                }
            }
        }

        return $this->decorated->denormalize($data, $class, $format, $context);
    }
public function denormalize($data, $class, $format = null, array $context = [])
    {
        if ($this->entityCollection->contains($class)) {
            $token = $this->tokenStorage->getToken();

            if (!$token) {
                throw new LogicException('Token is not defined.');
            }

            $attribute = Permission::EDIT;
            $subject = [
                0 => null,
                1 => null
            ];

            if (array_key_exists('object_to_populate', $context)) {
                $subject[0] = $context['object_to_populate'];
            } else {
                $object = new $context['resource_class'];

                foreach ($data as $property => $value) {
                    if (in_array($property, ['uuid', 'owner', 'ownerUuid', 'identity', 'identityUuid'], true)) {
                        // Set the required values for permission scope voters to vote on.
                        $object->{'set'.$property}($value);
                    }
                }

                $subject[0] = $object;
            }

            foreach (array_keys($data) as $property) {
                $subject[1] = $property;
                $vote = $this->voter->vote($token, $subject, [$attribute]);

                if (VoterInterface::ACCESS_ABSTAIN === $vote) {
                    throw new LogicException('Voter cannot abstain from voting.');
                }

                if (VoterInterface::ACCESS_DENIED === $vote) {
                    unset($data[$property]);
                }
            }
        }

        return $this->decorated->denormalize($data, $class, $format, $context);
    }
public function denormalize ( $ data , $ class , $ format = null , array $ context = [ ] ) { if ( $ this -> entityCollection -> contains ( $ class ) ) { $ token = $ this -> tokenStorage -> getToken ( ) ; if ( ! $ token ) { throw new LogicException ( 'Token is not defined.' ) ; } $ attribute = Permission :: EDIT ; $ subject = [ 0 => null , 1 => null ] ; if ( array_key_exists ( 'object_to_populate' , $ context ) ) { $ subject [ 0 ] = $ context [ 'object_to_populate' ] ; } else { $ object = new $ context [ 'resource_class' ] ; foreach ( $ data as $ property => $ value ) { if ( in_array ( $ property , [ 'uuid' , 'owner' , 'ownerUuid' , 'identity' , 'identityUuid' ] , true ) ) { // Set the required values for permission scope voters to vote on. $ object -> { 'set' . $ property } ( $ value ) ; } } $ subject [ 0 ] = $ object ; } foreach ( array_keys ( $ data ) as $ property ) { $ subject [ 1 ] = $ property ; $ vote = $ this -> voter -> vote ( $ token , $ subject , [ $ attribute ] ) ; if ( VoterInterface :: ACCESS_ABSTAIN === $ vote ) { throw new LogicException ( 'Voter cannot abstain from voting.' ) ; } if ( VoterInterface :: ACCESS_DENIED === $ vote ) { unset ( $ data [ $ property ] ) ; } } } return $ this -> decorated -> denormalize ( $ data , $ class , $ format , $ context ) ; }
{@inheritdoc}
{