本文整理汇总了PHP中Claroline\CoreBundle\Entity\User::getEntityRoles方法的典型用法代码示例。如果您正苦于以下问题:PHP User::getEntityRoles方法的具体用法?PHP User::getEntityRoles怎么用?PHP User::getEntityRoles使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Claroline\CoreBundle\Entity\User
的用法示例。
在下文中一共展示了User::getEntityRoles方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: findByUser
public function findByUser(User $user, $showAll = false)
{
$qb = $this->createQueryBuilder('f')->leftJoin('f.panelFacets', 'pf')->leftJoin('pf.fieldsFacet', 'ff')->leftJoin('ff.fieldsFacetValue', 'ffv');
if (!$showAll) {
$qb->join('f.roles', 'frole')->join('pf.panelFacetsRole', 'pfr')->andWhere('frole in (:roles)')->andWhere('pfr.role in (:roles)')->andWhere('pfr.canOpen = true')->setParameter('roles', $user->getEntityRoles());
}
return $qb->getQuery()->getResult();
}
示例2: checkRights
public function checkRights(User $user, $theRight)
{
if ($this->authorization->isGranted('ROLE_ADMIN')) {
return true;
}
$roles = $user->getEntityRoles();
$rights = $this->rightsRepo->findPresenceRightsByRolesAndValue($roles, $theRight);
return count($rights) > 0;
}
示例3: getTaggedWorkspacesByRoles
public function getTaggedWorkspacesByRoles(User $user, $tag, $orderedBy = 'id', $order = 'ASC')
{
$roles = $user->getEntityRoles();
return count($roles) > 0 ? $this->taggedObjectRepo->findTaggedWorkspacesByRoles($tag, $roles, $orderedBy, $order) : array();
}
示例4: desktopWidgetInstanceCreateAction
/**
* @EXT\Route(
* "desktop/hometab/{homeTab}/widget/instance/create",
* name="claro_desktop_widget_instance_create",
* options = {"expose"=true}
* )
* @EXT\Method("POST")
* @EXT\ParamConverter("user", options={"authenticatedUser" = true})
* @EXT\Template("ClarolineCoreBundle:Tool\desktop\home:desktopWidgetInstanceCreateModalForm.html.twig")
*
* Creates a widget instance.
*
* @return Response
*/
public function desktopWidgetInstanceCreateAction(User $user, HomeTab $homeTab)
{
$widgetInstance = new WidgetInstance();
$widgetDisplayConfig = new WidgetDisplayConfig();
$instanceForm = $this->formFactory->create(new WidgetInstanceType(true, true, $user->getEntityRoles()), $widgetInstance);
$displayConfigForm = $this->formFactory->create(new WidgetDisplayConfigType(), $widgetDisplayConfig);
$instanceForm->handleRequest($this->request);
$displayConfigForm->handleRequest($this->request);
if ($instanceForm->isValid() && $displayConfigForm->isValid()) {
$widgetInstance->setUser($user);
$widgetInstance->setIsAdmin(false);
$widgetInstance->setIsDesktop(true);
$widgetHomeTabConfig = new WidgetHomeTabConfig();
$widgetHomeTabConfig->setHomeTab($homeTab);
$widgetHomeTabConfig->setWidgetInstance($widgetInstance);
$widgetHomeTabConfig->setUser($user);
$widgetHomeTabConfig->setVisible(true);
$widgetHomeTabConfig->setLocked(false);
$widgetHomeTabConfig->setWidgetOrder(1);
$widgetHomeTabConfig->setType('desktop');
$widget = $widgetInstance->getWidget();
$widgetDisplayConfig->setWidgetInstance($widgetInstance);
$widgetDisplayConfig->setUser($user);
$widgetDisplayConfig->setWidth($widget->getDefaultWidth());
$widgetDisplayConfig->setHeight($widget->getDefaultHeight());
$this->widgetManager->persistWidgetConfigs($widgetInstance, $widgetHomeTabConfig, $widgetDisplayConfig);
return new JsonResponse(array('widgetInstanceId' => $widgetInstance->getId(), 'widgetHomeTabConfigId' => $widgetHomeTabConfig->getId(), 'widgetDisplayConfigId' => $widgetDisplayConfig->getId(), 'color' => $widgetDisplayConfig->getColor(), 'name' => $widgetInstance->getName(), 'configurable' => $widgetInstance->getWidget()->isConfigurable() ? 1 : 0, 'width' => $widget->getDefaultWidth(), 'height' => $widget->getDefaultHeight()), 200);
} else {
return array('homeTab' => $homeTab, 'instanceForm' => $instanceForm->createView(), 'displayConfigForm' => $displayConfigForm->createView());
}
}