protected static function hasTypeAccessBelongs(array $capabilities, array $user, array $url): bool
    {
        $entity = static::getEntityFromUrl($url);

        $userGroups = static::getUserGroups($user);

        foreach ($capabilities as $capability) {
            if (!static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                continue;
            }

            // if url does not include an id and user has belongs to capability
            // access, to current module action, allow him access. (index action)
            if (empty($entity)) {
                return true;
            }

            // if url includes an id, check capability's field value from the entity
            // against current user id and if they match allow him access. (view, edit actions etc)
            $field = $capability->getField();

            foreach (array_keys($userGroups) as $id) {
                if ($entity->get($field) === $id) {
                    return true;
                }
            }
        }

        return false;
    }
protected static function hasTypeAccessBelongs(array $capabilities, array $user, array $url): bool
    {
        $entity = static::getEntityFromUrl($url);

        $userGroups = static::getUserGroups($user);

        foreach ($capabilities as $capability) {
            if (!static::hasAccessInCapabilities($capability->getName(), $user['id'])) {
                continue;
            }

            // if url does not include an id and user has belongs to capability
            // access, to current module action, allow him access. (index action)
            if (empty($entity)) {
                return true;
            }

            // if url includes an id, check capability's field value from the entity
            // against current user id and if they match allow him access. (view, edit actions etc)
            $field = $capability->getField();

            foreach (array_keys($userGroups) as $id) {
                if ($entity->get($field) === $id) {
                    return true;
                }
            }
        }

        return false;
    }
protected static function hasTypeAccessBelongs ( array $ capabilities , array $ user , array $ url ) : bool { $ entity = static :: getEntityFromUrl ( $ url ) ; $ userGroups = static :: getUserGroups ( $ user ) ; foreach ( $ capabilities as $ capability ) { if ( ! static :: hasAccessInCapabilities ( $ capability -> getName ( ) , $ user [ 'id' ] ) ) { continue ; } // if url does not include an id and user has belongs to capability // access, to current module action, allow him access. (index action) if ( empty ( $ entity ) ) { return true ; } // if url includes an id, check capability's field value from the entity // against current user id and if they match allow him access. (view, edit actions etc) $ field = $ capability -> getField ( ) ; foreach ( array_keys ( $ userGroups ) as $ id ) { if ( $ entity -> get ( $ field ) === $ id ) { return true ; } } } return false ; }
Method that checks if user has belongs to access on Controller's action.

@param  mixed[]  $capabilities Action capabilities
@param  mixed[]  $user               User info
@param  mixed[]  $url                Controller url
@return bool
Method that checks if user has belongs to access on Controller s action .