/** * @param RoleInterface $role * * @return bool */ public function hasElementWithRole(RoleInterface $role) { $qa = $this->createAggregationQuery(); $qa->match(array('roles' => $role->getName())); $user = $this->singleHydrateAggregateQuery($qa); return $user instanceof UserInterface; }
/** * @param RoleInterface $role * * @return FacadeInterface * * @throws TransformerParameterTypeException */ public function transform($role) { if (!$role instanceof RoleInterface) { throw new TransformerParameterTypeException(); } $facade = $this->newFacade(); $facade->id = $role->getId(); $facade->name = $role->getName(); $facade->description = $this->multiLanguagesChoiceManager->choose($role->getDescriptions()); $facade->fromStatus = $role->getFromStatus(); $facade->toStatus = $role->getToStatus(); $facade->addLink('_self', $this->generateRoute('open_orchestra_api_role_show', array('roleId' => $role->getId()))); if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_DELETE_ROLE, $role) && !$this->usageFinder->hasUsage($role)) { $facade->addLink('_self_delete', $this->generateRoute('open_orchestra_api_role_delete', array('roleId' => $role->getId()))); } if ($this->authorizationChecker->isGranted(AdministrationPanelStrategy::ROLE_ACCESS_UPDATE_ROLE)) { $facade->addLink('_self_form', $this->generateRoute('open_orchestra_backoffice_role_form', array('roleId' => $role->getId()))); } return $facade; }
/** * @param string $message * @param RoleInterface $role */ protected function sendLog($message, RoleInterface $role) { $this->logger->info($message, array('role_name' => $role->getName())); }