本文整理汇总了PHP中Oro\Bundle\SecurityBundle\SecurityFacade::getLoggedUserId方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityFacade::getLoggedUserId方法的具体用法?PHP SecurityFacade::getLoggedUserId怎么用?PHP SecurityFacade::getLoggedUserId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\SecurityBundle\SecurityFacade
的用法示例。
在下文中一共展示了SecurityFacade::getLoggedUserId方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: checkPermissions
/**
* {@inheritdoc}
*/
public function checkPermissions($entity, ObjectManager $em)
{
$loggedUserId = $this->securityFacade->getLoggedUserId();
if ($loggedUserId && $loggedUserId == $entity->getId()) {
throw new ForbiddenException('self delete');
}
}
示例2: process
/**
* Process form
*
* @param CalendarEvent $entity
* @throws \LogicException
*
* @return bool True on successful processing, false otherwise
*/
public function process(CalendarEvent $entity)
{
if (!$entity->getCalendar()) {
if ($this->securityFacade->getLoggedUser() && $this->securityFacade->getOrganization()) {
/** @var Calendar $defaultCalendar */
$defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($this->securityFacade->getLoggedUser()->getId(), $this->securityFacade->getOrganization()->getId());
$entity->setCalendar($defaultCalendar);
} else {
throw new \LogicException('Current user did not define');
}
}
$this->form->setData($entity);
if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
$this->form->submit($this->request);
if ($this->form->isValid()) {
$targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
if ($targetEntityClass) {
$targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
$targetEntity = $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId);
$action = $this->entityRoutingHelper->getAction($this->request);
if ($action === 'activity') {
$this->activityManager->addActivityTarget($entity, $targetEntity);
}
if ($action === 'assign' && $targetEntity instanceof User && $targetEntityId !== $this->securityFacade->getLoggedUserId()) {
/** @var Calendar $defaultCalendar */
$defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($targetEntity->getId(), $targetEntity->getOrganization()->getId());
$entity->setCalendar($defaultCalendar);
}
}
$this->onSuccess($entity);
return true;
}
}
return false;
}
示例3: onMode
/**
* @param bool $isOn
*/
protected function onMode($isOn)
{
$userId = $this->securityFacade->getLoggedUserId();
try {
$this->publisher->send('oro/maintenance', array('isOn' => (bool) $isOn, 'userId' => $userId));
} catch (\Exception $e) {
$this->logger->error($e->getMessage());
}
}
示例4: checkPermissions
/**
* {@inheritdoc}
*/
protected function checkPermissions($entity, ObjectManager $em)
{
$loggedUserId = $this->securityFacade->getLoggedUserId();
if ($loggedUserId && $loggedUserId == $entity->getId()) {
throw new ForbiddenException('self delete');
}
if ($this->securityFacade->hasUserSidSharedRecords($entity)) {
throw new ForbiddenException('user has shared records');
}
parent::checkPermissions($entity, $em);
}
示例5: getUserCalendars
/**
* Gets a list of user's calendars for which it is granted to add events
*
* @return array of [id, name]
*/
public function getUserCalendars()
{
/** @var CalendarRepository $repo */
$repo = $this->doctrineHelper->getEntityRepository('OroCalendarBundle:Calendar');
$calendars = $repo->getUserCalendarsQueryBuilder($this->securityFacade->getOrganizationId(), $this->securityFacade->getLoggedUserId())->select('c.id, c.name')->getQuery()->getArrayResult();
foreach ($calendars as &$calendar) {
if (empty($calendar['name'])) {
$calendar['name'] = $this->entityNameResolver->getName($this->securityFacade->getLoggedUser());
}
}
return $calendars;
}
示例6: onBuildAfter
/**
* @param BuildAfter $event
*/
public function onBuildAfter(BuildAfter $event)
{
$datagrid = $event->getDatagrid();
$datasource = $datagrid->getDatasource();
if ($datasource instanceof OrmDatasource) {
$parameters = $datagrid->getParameters();
$userId = $parameters->get('userId');
if (!$userId) {
$userId = $this->securityFacade->getLoggedUserId();
}
$datasource->getQueryBuilder()->andWhere(sprintf('task.owner = %d', $userId));
}
}
示例7: searchIds
/**
* {@inheritdoc}
*/
protected function searchIds($search, $firstResult, $maxResults)
{
$userIds = parent::searchIds($search, $firstResult, $maxResults + 1);
$excludedKey = null;
$currentUserId = $this->securityFacade->getLoggedUserId();
if ($currentUserId) {
$excludedKey = array_search($currentUserId, $userIds);
}
if (false !== $excludedKey) {
unset($userIds[$excludedKey]);
$userIds = array_values($userIds);
} else {
$userIds = array_slice($userIds, 0, $maxResults);
}
return $userIds;
}
示例8: process
/**
* Process form
*
* @param CalendarEvent $entity
*
* @throws \LogicException
*
* @return bool True on successful processing, false otherwise
*/
public function process(CalendarEvent $entity)
{
$this->form->setData($entity);
if (in_array($this->request->getMethod(), array('POST', 'PUT'))) {
$originalChildren = new ArrayCollection();
foreach ($entity->getChildEvents() as $childEvent) {
$originalChildren->add($childEvent);
}
$this->form->submit($this->request);
if ($this->form->isValid()) {
$this->ensureCalendarSet($entity);
$targetEntityClass = $this->entityRoutingHelper->getEntityClassName($this->request);
if ($targetEntityClass) {
$targetEntityId = $this->entityRoutingHelper->getEntityId($this->request);
$targetEntity = $this->entityRoutingHelper->getEntityReference($targetEntityClass, $targetEntityId);
$action = $this->entityRoutingHelper->getAction($this->request);
if ($action === 'activity') {
$this->activityManager->addActivityTarget($entity, $targetEntity);
}
if ($action === 'assign' && $targetEntity instanceof User && $targetEntityId !== $this->securityFacade->getLoggedUserId()) {
/** @var Calendar $defaultCalendar */
$defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($targetEntity->getId(), $targetEntity->getOrganization()->getId());
$entity->setCalendar($defaultCalendar);
}
}
$this->onSuccess($entity, $originalChildren, $this->form->get('notifyInvitedUsers')->getData());
return true;
}
}
return false;
}
示例9: onModeOff
public function onModeOff()
{
$userId = $this->securityFacade->getLoggedUserId();
$this->publisher->send('oro/maintenance', array('isOn' => false, 'userId' => $userId));
}
示例10: getBasicQueryBuilder
/**
* Returns query builder that uses to build query for search bu id or by search string.
* Result data limit by users that was have access to the current organization and excluding current user.
*
* @return QueryBuilder
*/
protected function getBasicQueryBuilder()
{
$queryBuilder = $this->entityRepository->createQueryBuilder('u');
$queryBuilder->join('u.organizations', 'org')->andWhere('org.id = :org')->andWhere('u.id != :currentUser')->setParameter('org', $this->securityFacade->getOrganizationId())->setParameter('currentUser', $this->securityFacade->getLoggedUserId());
return $queryBuilder;
}