设置客服账号头像
@param string $accountName
@param string $avatarPath
@return bool
@throws \yii\web\HttpException
173798
public function setAccountAvatar($accountName, $avatarPath)
    {
        $result = $this->wechat->httpPost(self::WECHAT_ACCOUNT_AVATAR_SET_PREFIX, [
            'media' => $this->wechat->uploadFile($avatarPath)
        ], [
            'access_token' => $this->wechat->getAccessToken(),
            'kf_account' => $accountName
        ]);
        return isset($result['errmsg']) && $result['errmsg'] == 'ok';
    }
1205845
private function imageExists($imagePath, $imageSrc = null)
    {
        // If image name is sewhere parameter
        if (isset($imageSrc)) {
            // Form path to the image
            $imageFullPath = $this->formImagePath($imagePath, $imageSrc);
        } else {
            // Path was already set
            $imageFullPath = $imagePath;
        }

        // Call file service existence method
        return $this->fs->exists($imageFullPath);
    }
1125051
public function equals(Account $account): bool
    {
        if ($this->name !== $account->name) {
            return false;
        }

        if (!$this->homePage->equals($account->homePage)) {
            return false;
        }

        return true;
    }
951119
public function open($savePath, $sessionName): bool
    {
        $sessionId = session_id();

        $identifier = $this->cryptProvider->makeSessionIdentifier($sessionId);

        while (!$this->storageDriver->lock($identifier)) {
            usleep(1000);
        }

        return true;
    }
154989
public function findAvatars($username)
    {
        $parameters['username'] = $username;
        return $this->apiClient->callEndpoint(sprintf('%s/avatars', self::ENDPOINT), $parameters);
    }
215281
public function isEasyAdminGranted(array $entityConfig, string $actionName, $subject = null)
    {
        try {
            $this->checksUserAccess($entityConfig, $actionName, $subject);
        } catch (AccessDeniedException $e) {
            return false;
        }

        return true;
    }
597812
private function isOwner(AccountInterface $account, Model $resource)
    {
        /** @var Model $resource */
        if ($this->isAuthenticated($account) === true) {
            $userId  = $account->getAuthIdentifier();
            $ownerId = $resource->{Model::FIELD_ID_USER};
            $isOwner = $userId === $ownerId;

            return $isOwner;
        }

        return false;
    }
283415
public T accountPath(ImmutableList<ChildNumber> accountPath) {
            checkState(watchingKey == null, "either watch or accountPath");
            this.accountPath = checkNotNull(accountPath);
            return self();
        }
1233323
public function getToken($userId, $name, $portraitUri) {
        try{
            if(empty($userId))
                throw new Exception('用户 Id 不能为空');
            if(empty($name))
                throw new Exception('用户名称 不能为空');
            if(empty($portraitUri))
                throw new Exception('用户头像 URI 不能为空');

            $ret = Cache::rememberForever($userId, function() use($userId, $name, $portraitUri){
                return $this->curl('/user/getToken',array('userId'=>$userId,'name'=>$name,'portraitUri'=>$portraitUri));
            });
            
            if(empty($ret))
                throw new Exception('请求失败');

            return $ret;

        }catch (Exception $e) {
            print_r($e->getMessage());
        }
    }
1107464
def delete_user_avatar(self, username, avatar):
        
        params = {'username': username}
        url = self._get_url('user/avatar/' + avatar)
        return self._session.delete(url, params=params)
139412
public function deleteAvatar($projectId, $avatarId)
    {
        return $this->apiClient->callEndpoint(
            sprintf('%s/%s/avatar/%s', self::ENDPOINT, $projectId, $avatarId),
            array(),
            null,
            HttpMethod::REQUEST_DELETE
        );
    }
896180
public static function assetUrl($name, $version = false)
    {
        // Global app
        global $app;

        // Get cache
        $cache = Cache::get('potion_assets', []);

        // Check for asset
        if (!isset($cache[$name])) {
            return false;
        }

        // Get config
        $config = (isset($app['config']['potion']) ? $app['config']['potion'] : false);

        // Get Url
        $ret = rtrim($config['base_url'], '/');

        // Add name
        $name = ltrim($name, '/');
        $ret .= "/{$name}";

        // Version?
        if ($version) {
            $ret .= "v={$cache[$name]}";
        }

        return $ret;
    }
934245
protected function findRole($roleName)
    {
        if (($role = $this->_authManager->getRole($roleName)) !== null) {
            return $role;
        }

        throw new Exception(Yii::t('yii2mod.user', 'The role "{roleName}" is not found.', [
            'roleName' => $roleName,
        ]));
    }
830299
protected function isAdmin(AccountInterface $account)
    {
        /** @var Model $resource */
        if ($this->isAuthenticated($account) === true) {
            /** @var User $user */
            $user    = $account->user();
            $isAdmin = $user->hasRole(Role::ENUM_ROLE_ADMIN_ID);

            return $isAdmin;
        }

        return false;
    }
603915
public function open($savePath, $sessionName)
    {
        $this->savePath = $savePath;
        if (!is_dir($this->savePath)) {
            mkdir($this->savePath, 0777);
        }

        return true;
    }
909446
public function findActiveByAccountIdentifierAndAuthenticationProviderName($accountIdentifier, $authenticationProviderName)
    {
        $query = $this->createQuery();
        return $query->matching(
            $query->logicalAnd(
                $query->equals('accountIdentifier', $accountIdentifier),
                $query->equals('authenticationProviderName', $authenticationProviderName),
                $query->logicalOr(
                    $query->equals('expirationDate', null),
                    $query->greaterThan('expirationDate', new \DateTime())
                )
            )
        )->execute()->getFirst();
    }
703570
public function open($savePath, $sessionName): bool
    {
        parent::open($savePath, $sessionName);

        $this->handler = new \Redis();

        if ($this->settings['persistence']) {
            $this->handler->pconnect($this->settings['host'], $this->settings['port'], $this->settings['timeout']);
        } else {
            $this->handler->connect($this->settings['host'], $this->settings['port'], $this->settings['timeout']);
        }

        if (isset($this->settings['options'])) {
            foreach ($this->settings['options'] as $key => $value) {
                $this->handler->setOption($key, $value);
            }
        }

        return true;
    }