/** * Returns logged-in userId or anonymous sessionId. * * @return int|string */ private function getCurrentUserId() { if ($this->authorizationChecker->isGranted('IS_AUTHENTICATED_FULLY') | $this->authorizationChecker->isGranted('IS_AUTHENTICATED_REMEMBERED')) { return $this->repository->getCurrentUser()->id; } else { return $this->session->get('yc-session-id'); } }
/** * Gets ContentType ID based on $contentId. * * @param mixed $contentId * * @return int|null */ protected function getContentTypeId($contentId) { $contentService = $this->repository->getContentService(); $contentTypeId = null; try { $contentTypeId = $contentService->loadContentInfo($contentId)->contentTypeId; } catch (Exception $e) { } return $contentTypeId; }
public function __construct(Repository $repository) { $this->repository = $repository; $this->service = $this->repository->getContentTypeService(); }
/** * Permite definir el usuario actual * @param integer $user_id id del usuario a definir */ protected function setCurrentUser($user_id) { $this->currentUser = $this->repository->getUserService()->loadUser($user_id); $this->repository->setCurrentUser($this->currentUser); return $this; }