src/AppBundle/Security/Contabilidad/EgresoVoter.php
/**
     * Perform a single access check operation on a given attribute, subject and token.
     * It is safe to assume that $attribute and $subject already passed the "supports()" method check.
     *
     * @param string $attribute
     * @param mixed $subject
     * @param TokenInterface $token
     *
     * @return bool
     */
Perform a single access check operation on a given attribute, subject and token.
It is safe to assume that $attribute and $subject already passed the "supports()" method check.



@return bool
Perform a single access check operation on a given attribute subject and token . It is safe to assume that $attribute and $subject already passed the " supports () " method check . @return bool
protected function voteOnAttribute($attribute, $subject, TokenInterface $token)
    {
        $user = $token->getUser();
        if (!$user instanceof Usuario) {
            return false;
        }
        if ($this->decisionManager->decide($token, ['ROLE_ADMIN'])) {
            return true;
        }
        $egreso = $subject;
        $empresas = [];
        foreach ($user->getRoles() as $role) {
            if (strpos($role, 'VIEW_EGRESO') === 0) {
                $empresas[] = explode('_', $role)[3];
            }
        }
        switch ($attribute) {
            case self::VIEW:
                return $this->canView($egreso, $user, $empresas);
            case self::EDIT:
                return $this->canEdit($egreso, $user, $empresas);
        }
    }
protected function voteOnAttribute ( $ attribute , $ subject , TokenInterface $ token ) { $ user = $ token -> getUser ( ) ; if ( ! $ user instanceof Usuario ) { return false ; } if ( $ this -> decisionManager -> decide ( $ token , [ 'ROLE_ADMIN' ] ) ) { return true ; } $ egreso = $ subject ; $ empresas = [ ] ; foreach ( $ user -> getRoles ( ) as $ role ) { if ( strpos ( $ role , 'VIEW_EGRESO' ) === 0 ) { $ empresas [ ] = explode ( '_' , $ role ) [ 3 ] ; } } switch ( $ attribute ) { case self :: VIEW : return $ this -> canView ( $ egreso , $ user , $ empresas ) ; case self :: EDIT : return $ this -> canEdit ( $ egreso , $ user , $ empresas ) ; } }
Perform a single access check operation on a given attribute, subject and token.
Perform a single access check operation on a given attribute subject and token .
/** @var Egreso $subject */