private function voteAccess(DefinitionInterface $definition, $attribute) { if ($attribute === 'CRUDIFY_CREATE') { if ($definition->withCreate()) { return $this->defaultAccess; } else { return VoterInterface::ACCESS_DENIED; } } if ($attribute === 'CRUDIFY_UPDATE') { if ($definition->withUpdate()) { return $this->defaultAccess; } else { return VoterInterface::ACCESS_DENIED; } } if ($attribute === 'CRUDIFY_DELETE') { if ($definition->withDelete()) { return $this->defaultAccess; } else { return VoterInterface::ACCESS_DENIED; } } return $this->defaultAccess; }
function it_should_not_allow_update_access_if_the_definition_denies(DefinitionInterface $definition, TokenInterface $token) { $definition->withUpdate()->willReturn(false); $this->vote($token, $definition, ['CRUDIFY_UPDATE'])->shouldReturn(VoterInterface::ACCESS_DENIED); }