本文整理汇总了PHP中Oro\Bundle\SecurityBundle\SecurityFacade::getToken方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityFacade::getToken方法的具体用法?PHP SecurityFacade::getToken怎么用?PHP SecurityFacade::getToken使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\SecurityBundle\SecurityFacade
的用法示例。
在下文中一共展示了SecurityFacade::getToken方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: process
/**
* Process form
*
* @param AccountUser $accountUser
* @return bool True on successful processing, false otherwise
*/
public function process(AccountUser $accountUser)
{
if (in_array($this->request->getMethod(), ['POST', 'PUT'], true)) {
$this->form->submit($this->request);
if ($this->form->isValid()) {
if (!$accountUser->getId()) {
if ($this->form->get('passwordGenerate')->getData()) {
$generatedPassword = $this->userManager->generatePassword(10);
$accountUser->setPlainPassword($generatedPassword);
}
if ($this->form->get('sendEmail')->getData()) {
$this->userManager->sendWelcomeEmail($accountUser);
}
}
$token = $this->securityFacade->getToken();
if ($token instanceof OrganizationContextTokenInterface) {
$organization = $token->getOrganizationContext();
$accountUser->setOrganization($organization)->addOrganization($organization);
}
$this->userManager->updateUser($accountUser);
return true;
}
}
return false;
}
示例2: linkToScope
/**
* @param EmailBodyAdded $event
*/
public function linkToScope(EmailBodyAdded $event)
{
if ($this->securityFacade->getToken() !== null && !$this->securityFacade->isGranted('CREATE', 'entity:' . AttachmentScope::ATTACHMENT)) {
return;
}
$email = $event->getEmail();
$entities = $this->activityListProvider->getTargetEntities($email);
foreach ($entities as $entity) {
if ((bool) $this->configProvider->getConfig(ClassUtils::getClass($entity))->get('auto_link_attachments')) {
foreach ($email->getEmailBody()->getAttachments() as $attachment) {
$this->attachmentManager->linkEmailAttachmentToTargetEntity($attachment, $entity);
}
}
}
}
示例3: getCurrentEmailUser
/**
* Find EmilUser User logged in system
*
* @param Email $entity - entity Email
*
* @return null|EmailUser
*/
protected function getCurrentEmailUser(Email $entity)
{
$user = $this->securityFacade->getToken()->getUser();
$currentOrganization = $this->securityFacade->getOrganization();
$emailUser = $this->em->getRepository('OroEmailBundle:EmailUser')->findByEmailAndOwner($entity, $user, $currentOrganization);
return $emailUser;
}
示例4: processAcl
/**
* Check ACL based on acl_resource_id, route or uri.
*
* @param array $options
*
* @return void
*/
protected function processAcl(array &$options = array())
{
$isAllowed = self::DEFAULT_ACL_POLICY;
$options['extras']['isAllowed'] = self::DEFAULT_ACL_POLICY;
if (isset($options['check_access']) && $options['check_access'] === false) {
return;
}
if ($this->hideAllForNotLoggedInUsers && !$this->securityFacade->hasLoggedUser()) {
if (isset($options['extras']) && array_key_exists('showNonAuthorized', $options['extras']) && $options['extras']['showNonAuthorized']) {
return;
}
$isAllowed = false;
} elseif ($this->securityFacade->getToken() !== null) {
// don't check access if it's CLI
if (array_key_exists('extras', $options) && array_key_exists(self::ACL_POLICY_KEY, $options['extras'])) {
$isAllowed = $options['extras'][self::ACL_POLICY_KEY];
}
if (array_key_exists(self::ACL_RESOURCE_ID_KEY, $options)) {
if (array_key_exists($options[self::ACL_RESOURCE_ID_KEY], $this->aclCache)) {
$isAllowed = $this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]];
} else {
$isAllowed = $this->securityFacade->isGranted($options[self::ACL_RESOURCE_ID_KEY]);
$this->aclCache[$options[self::ACL_RESOURCE_ID_KEY]] = $isAllowed;
}
} else {
$routeInfo = $this->getRouteInfo($options);
if ($routeInfo) {
if (array_key_exists($routeInfo['key'], $this->aclCache)) {
$isAllowed = $this->aclCache[$routeInfo['key']];
} else {
$isAllowed = $this->securityFacade->isClassMethodGranted($routeInfo['controller'], $routeInfo['action']);
$this->aclCache[$routeInfo['key']] = $isAllowed;
}
}
}
}
$options['extras']['isAllowed'] = $isAllowed;
}
示例5: getCurrentEmailUser
/**
* Find EmilUser User logged in system
*
* @param Email $entity - entity Email
*
* @return EmailUser[]
*/
protected function getCurrentEmailUser(Email $entity)
{
$user = $this->securityFacade->getToken()->getUser();
$currentOrganization = $this->securityFacade->getOrganization();
return array_merge($this->getEmailUserRepository()->findByEmailAndOwner($entity, $user, $currentOrganization), $this->getEmailUserRepository()->findByEmailForMailbox($entity));
}
示例6: isApplicable
/**
* {@inheritdoc}
*/
public function isApplicable(DatagridConfiguration $config)
{
$className = $this->getEntityClassName($config);
return !$this->isReportOrSegmentGrid($config) && $className && $this->taggableHelper->isTaggable($className) && null !== $config->offsetGetByPath(self::PROPERTY_ID_PATH) && null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view');
}
示例7: getUser
/**
* @return User
*/
protected function getUser()
{
return $this->securityFacade->getToken()->getUser();
}
示例8: isAccessGranted
/**
* @return bool
*/
protected function isAccessGranted()
{
return null !== $this->securityFacade->getToken() && $this->securityFacade->isGranted('oro_tag_view');
}