当前位置: 首页>>代码示例>>PHP>>正文


PHP Repository::getCurrentUser方法代码示例

本文整理汇总了PHP中eZ\Publish\API\Repository\Repository::getCurrentUser方法的典型用法代码示例。如果您正苦于以下问题:PHP Repository::getCurrentUser方法的具体用法?PHP Repository::getCurrentUser怎么用?PHP Repository::getCurrentUser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在eZ\Publish\API\Repository\Repository的用法示例。


在下文中一共展示了Repository::getCurrentUser方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onKernelBuilt

 /**
  * Performs actions related to security once the legacy kernel has been built.
  *
  * @param PostBuildKernelEvent $event
  */
 public function onKernelBuilt(PostBuildKernelEvent $event)
 {
     // Ignore if not in web context, if legacy_mode is active or if user is not authenticated
     if ($this->enabled === false || !$event->getKernelHandler() instanceof ezpWebBasedKernelHandler || $this->configResolver->getParameter('legacy_mode') === true || !$this->isUserAuthenticated()) {
         return;
     }
     $currentUser = $this->repository->getCurrentUser();
     $event->getLegacyKernel()->runCallback(function () use($currentUser) {
         $legacyUser = eZUser::fetch($currentUser->id);
         eZUser::setCurrentlyLoggedInUser($legacyUser, $legacyUser->attribute('contentobject_id'), eZUser::NO_SESSION_REGENERATE);
     }, false, false);
 }
开发者ID:dfritschy,项目名称:ezpublish-kernel,代码行数:17,代码来源:Security.php

示例2: getView

 public function getView(Location $location, $viewType)
 {
     if ($viewType !== 'full') {
         return null;
     }
     if ($location->getContentInfo()->sectionId !== $this->premiumSectionId) {
         return null;
     }
     if ($this->subscriptionChecker->userIsSubscriber($this->repository->getCurrentUser())) {
         return null;
     }
     return new ContentView("eZDemoBundle:{$viewType}:premium_content.html.twig");
 }
开发者ID:vidarl,项目名称:DemoBundle,代码行数:13,代码来源:PremiumLocationViewProvider.php

示例3: copyContentType

    /**
     * Copy Type incl fields and groupIds to a new Type object
     *
     * New Type will have $creator as creator / modifier, created / modified should be updated with current time,
     * updated remoteId and identifier should be appended with '_' + unique string.
     *
     * @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException if the current-user is not allowed to copy a content type
     *
     * @param \eZ\Publish\API\Repository\Values\ContentType\ContentType $contentType
     * @param \eZ\Publish\API\Repository\Values\User\User $creator if null the current-user is used
     *
     * @return \eZ\Publish\API\Repository\Values\ContentType\ContentType
     */
    public function copyContentType( APIContentType $contentType, User $creator = null )
    {
        if ( $this->repository->hasAccess( 'class', 'create' ) !== true )
            throw new UnauthorizedException( 'ContentType', 'create' );

        if ( empty( $creator ) )
        {
            $creator = $this->repository->getCurrentUser();
        }

        $this->repository->beginTransaction();
        try
        {
            $spiContentType = $this->contentTypeHandler->copy(
                $creator->id,
                $contentType->id,
                SPIContentType::STATUS_DEFINED
            );
            $this->repository->commit();
        }
        catch ( Exception $e )
        {
            $this->repository->rollback();
            throw $e;
        }

        return $this->loadContentType( $spiContentType->id );
    }
开发者ID:ezsystemstraining,项目名称:ez54training,代码行数:41,代码来源:ContentTypeService.php

示例4: getView

 public function getView(View $view)
 {
     $viewType = $view->getViewType();
     if ($viewType !== 'full') {
         return null;
     }
     if (!$view instanceof ContentValueView) {
         return null;
     }
     if ($view->getContent()->contentInfo->sectionId !== $this->premiumSectionId) {
         return null;
     }
     if ($this->subscriptionChecker->userIsSubscriber($this->repository->getCurrentUser())) {
         return null;
     }
     return new ContentView("eZDemoBundle:{$viewType}:premium_content.html.twig");
 }
开发者ID:ezsystems,项目名称:demobundle,代码行数:17,代码来源:PremiumLocationViewProvider.php

示例5: deleteUser

 /**
  * Given user is deleted.
  *
  * @param $userId
  *
  * @throws \eZ\Publish\Core\REST\Server\Exceptions\ForbiddenException
  *
  * @return \eZ\Publish\Core\REST\Server\Values\NoContent
  */
 public function deleteUser($userId)
 {
     $user = $this->userService->loadUser($userId);
     if ($user->id == $this->repository->getCurrentUser()->id) {
         throw new Exceptions\ForbiddenException('Currently authenticated user cannot be deleted');
     }
     $this->userService->deleteUser($user);
     return new Values\NoContent();
 }
开发者ID:ezsystems,项目名称:ezpublish-kernel,代码行数:18,代码来源:User.php

示例6: refreshSession

 /**
  * Refresh given session.
  *
  * @param string $sessionId
  *
  * @throws \eZ\Publish\Core\REST\Common\Exceptions\NotFoundException
  * @return \eZ\Publish\Core\REST\Server\Values\UserSession
  */
 public function refreshSession($sessionId)
 {
     /** @var $session \Symfony\Component\HttpFoundation\Session\Session */
     $session = $this->request->getSession();
     $inputCsrf = $this->request->headers->get('X-CSRF-Token');
     if (!$session->isStarted() || $session->getId() != $sessionId || $session == null) {
         throw new RestNotFoundException("Session not valid");
     }
     return new Values\UserSession($this->repository->getCurrentUser(), $session->getName(), $session->getId(), $inputCsrf, false);
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:18,代码来源:User.php

示例7: getCurrentUser

 /**
  * Return the user object of the current user as well as an information, whether the user is
  * logged in.
  *
  * @return array Array containing the user object and a boolean, whether the user is logged in.
  * <pre>
  *  array(
  *      'content'  => Values\User\User object,
  *      'isLogged' => false
  *  )
  * </pre>
  */
 public function getCurrentUser()
 {
     $currentUser = $this->repository->getCurrentUser();
     $result = array();
     //        $result['versionInfo'] = $currentUser->versionInfo;
     $result['content'] = $currentUser;
     $result['isLogged'] = false;
     // TODO => deprecated function call *loadAnonymousUser()*
     $anonymousUserId = $this->userService->loadAnonymousUser()->content->versionInfo->contentInfo->id;
     if ($anonymousUserId && $anonymousUserId != $currentUser->id) {
         $result['isLogged'] = true;
     }
     return $result;
 }
开发者ID:intermundiasolutions,项目名称:CjwPublishToolsBundle,代码行数:26,代码来源:PublishToolsService.php

示例8: getCurrentUser

 /**
  * Get current user
  *
  * @return \eZ\Publish\API\Repository\Values\User\User
  */
 public function getCurrentUser()
 {
     return $this->repository->getCurrentUser();
 }
开发者ID:CG77,项目名称:ezpublish-kernel,代码行数:9,代码来源:Repository.php


注:本文中的eZ\Publish\API\Repository\Repository::getCurrentUser方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。