private function getUserRoleCacheValue(AccountInterface $account, Site $site = null)
    {
        $userId = $account->id();

        if (!isset($this->accessCache[$userId])) {
            $r = $this
                ->db
                ->query(
                    "
                        SELECT
                            a.uid, a.site_id, a.role, s.state AS site_state,
                            u.name, u.mail, u.status
                        FROM {ucms_site_access} a
                        JOIN {users} u
                            ON u.uid = a.uid
                        JOIN {ucms_site} s
                            ON s.id = a.site_id
                        WHERE
                            a.uid = :userId
                    ",
                    [':userId' => $userId]
                )
            ;

            $r->setFetchMode(\PDO::FETCH_CLASS, SiteAccessRecord::class);

            // Can't use fetchAllAssoc() because properties are private on the
            // objects built by PDO
            $this->accessCache[$userId] = [];
            foreach ($r->fetchAll() as $record) {
                $this->accessCache[$userId][$record->getSiteId()] = $record;
            }
        }

        if (null !== $site) {
            if (!empty($this->accessCache[$userId][$site->id])) {
                return $this->accessCache[$userId][$site->id];
            } else {
                return Access::ROLE_NONE;
            }
        }

        return $this->accessCache[$userId];
    }
private function getUserRoleCacheValue(AccountInterface $account, Site $site = null)
    {
        $userId = $account->id();

        if (!isset($this->accessCache[$userId])) {
            $r = $this
                ->db
                ->query(
                    "
                        SELECT
                            a.uid, a.site_id, a.role, s.state AS site_state,
                            u.name, u.mail, u.status
                        FROM {ucms_site_access} a
                        JOIN {users} u
                            ON u.uid = a.uid
                        JOIN {ucms_site} s
                            ON s.id = a.site_id
                        WHERE
                            a.uid = :userId
                    ",
                    [':userId' => $userId]
                )
            ;

            $r->setFetchMode(\PDO::FETCH_CLASS, SiteAccessRecord::class);

            // Can't use fetchAllAssoc() because properties are private on the
            // objects built by PDO
            $this->accessCache[$userId] = [];
            foreach ($r->fetchAll() as $record) {
                $this->accessCache[$userId][$record->getSiteId()] = $record;
            }
        }

        if (null !== $site) {
            if (!empty($this->accessCache[$userId][$site->id])) {
                return $this->accessCache[$userId][$site->id];
            } else {
                return Access::ROLE_NONE;
            }
        }

        return $this->accessCache[$userId];
    }
private function getUserRoleCacheValue ( AccountInterface $ account , Site $ site = null ) { $ userId = $ account -> id ( ) ; if ( ! isset ( $ this -> accessCache [ $ userId ] ) ) { $ r = $ this -> db -> query ( "
                        SELECT
                            a.uid, a.site_id, a.role, s.state AS site_state,
                            u.name, u.mail, u.status
                        FROM {ucms_site_access} a
                        JOIN {users} u
                            ON u.uid = a.uid
                        JOIN {ucms_site} s
                            ON s.id = a.site_id
                        WHERE
                            a.uid = :userId
                    " , [ ':userId' => $ userId ] ) ; $ r -> setFetchMode ( \ PDO :: FETCH_CLASS , SiteAccessRecord :: class ) ; // Can't use fetchAllAssoc() because properties are private on the // objects built by PDO $ this -> accessCache [ $ userId ] = [ ] ; foreach ( $ r -> fetchAll ( ) as $ record ) { $ this -> accessCache [ $ userId ] [ $ record -> getSiteId ( ) ] = $ record ; } } if ( null !== $ site ) { if ( ! empty ( $ this -> accessCache [ $ userId ] [ $ site -> id ] ) ) { return $ this -> accessCache [ $ userId ] [ $ site -> id ] ; } else { return Access :: ROLE_NONE ; } } return $ this -> accessCache [ $ userId ] ; }
Get user role in site

@param AccountInterface $account
@param Site $site

@return SiteAccessRecord|SiteAccessRecord[]
Get user role in site