本文整理汇总了PHP中Oro\Bundle\SecurityBundle\SecurityFacade::getOrganization方法的典型用法代码示例。如果您正苦于以下问题:PHP SecurityFacade::getOrganization方法的具体用法?PHP SecurityFacade::getOrganization怎么用?PHP SecurityFacade::getOrganization使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Oro\Bundle\SecurityBundle\SecurityFacade
的用法示例。
在下文中一共展示了SecurityFacade::getOrganization方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createExistingEntityQueryBuilder
/**
* @param EmailTemplate $template
*
* @return Closure
*/
protected function createExistingEntityQueryBuilder(EmailTemplate $template)
{
return function (EmailTemplateRepository $repository) use($template) {
$qb = $repository->createQueryBuilder('e');
return $qb->orderBy('e.name', 'ASC')->andWhere('e.entityName = :entityName OR e.entityName IS NULL')->andWhere("e.organization = :organization")->andWhere($qb->expr()->orX($qb->expr()->eq('e.visible', ':visible'), $qb->expr()->eq('e.id', ':id')))->setParameter('entityName', Email::ENTITY_CLASS)->setParameter('organization', $this->securityFacade->getOrganization())->setParameter('id', $template->getId())->setParameter('visible', true);
};
}
示例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: createChoices
/**
* @return array
*/
protected function createChoices()
{
$user = $this->securityFacade->getLoggedUser();
if (!$user instanceof User) {
return [];
}
$emails = array_merge(array_values($this->relatedEmailsProvider->getEmails($user, 1, true)), $this->mailboxManager->findAvailableMailboxEmails($user, $this->securityFacade->getOrganization()));
return array_combine($emails, $emails);
}
示例4: setSeenStatus
/**
* Set email seen status for current user for single email or thread
*
* @param Email $entity
* @param bool $isSeen
* @param bool $checkThread - if false it will be applied for single email instead of thread
*/
public function setSeenStatus(Email $entity, $isSeen = true, $checkThread = false)
{
$user = $this->securityFacade->getLoggedUser();
$organization = $this->securityFacade->getOrganization();
$emailUsers = $this->getEmailUserRepository()->getAllEmailUsersByEmail($entity, $user, $organization, $checkThread);
foreach ($emailUsers as $emailUser) {
$this->setEmailUserSeen($emailUser, $isSeen);
}
$this->em->flush();
}
示例5: fillEntityData
/**
* @param string $key
* @param Organization $entity
*/
public function fillEntityData($key, $entity)
{
switch ($key) {
case 'default':
$organization = $this->securityFacade->getOrganization();
if ($organization) {
$entity->setName($organization->getName());
}
return;
}
parent::fillEntityData($key, $entity);
}
示例6: getVariables
/**
* @param bool $addValue FALSE for variable definitions; TRUE for variable values
*
* @return array
*/
protected function getVariables($addValue)
{
$result = [];
$organization = $this->securityFacade->getOrganization();
$user = $this->securityFacade->getLoggedUser();
$this->addOrganizationName($result, $organization, $addValue);
$this->addUserName($result, $user, $addValue);
$this->addUserFirstName($result, $user, $addValue);
$this->addUserLastName($result, $user, $addValue);
$this->addUserFullName($result, $user, $addValue);
return $result;
}
示例7: process
/**
* {@inheritdoc}
*/
public function process(User $user)
{
if ($this->securityFacade !== null && $user->getCurrentOrganization() === null) {
$user->setCurrentOrganization($this->securityFacade->getOrganization());
}
$this->form->setData($user);
if (in_array($this->request->getMethod(), ['POST', 'PUT'])) {
$this->form->submit($this->request);
if ($this->form->isValid()) {
$this->onSuccess($user);
return true;
}
}
return false;
}
示例8: applyAcl
/**
* Apply custom ACL checks
*
* @param QueryBuilder $qb
*/
public function applyAcl(QueryBuilder $qb)
{
$user = $this->securityFacade->getLoggedUser();
$organization = $this->securityFacade->getOrganization();
$mailboxIds = $this->doctrine->getRepository('OroEmailBundle:Mailbox')->findAvailableMailboxIds($user, $organization);
$uoCheck = $qb->expr()->andX($qb->expr()->eq('eu.owner', ':owner'), $qb->expr()->eq('eu.organization ', ':organization'));
if (!empty($mailboxIds)) {
$qb->andWhere($qb->expr()->orX($uoCheck, $qb->expr()->in('eu.mailboxOwner', ':mailboxIds')));
$qb->setParameter('mailboxIds', $mailboxIds);
} else {
$qb->andWhere($uoCheck);
}
$qb->setParameter('owner', $user->getId());
$qb->setParameter('organization', $organization->getId());
}
示例9: searchIds
/**
* @param string $search
* @param int $firstResult
* @param int $maxResults
*
* @return array
*/
protected function searchIds($search, $firstResult, $maxResults)
{
$ids = parent::searchIds($search, $firstResult, $maxResults);
// Need to make additional query cause of Mysql Full-Text Search limitation and databases stop words.
// http://dev.mysql.com/doc/refman/5.0/en/server-system-variables.html#sysvar_ft_min_word_len
// http://dev.mysql.com/doc/refman/5.0/en/fulltext-stopwords.html
// http://www.postgresql.org/docs/9.1/static/textsearch-dictionaries.html
$object = $this->entityRepository->findOneBy(['name' => $search, 'organization' => $this->securityFacade->getOrganization()]);
if ($object !== null) {
$id = $object->getId();
if (!in_array($id, $ids, true)) {
$ids[] = $id;
}
}
return $ids;
}
示例10: 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;
}
示例11: addOwnerOrganizationEventListener
/**
* @param FormBuilderInterface $builder
*/
protected function addOwnerOrganizationEventListener(FormBuilderInterface $builder)
{
$builder->addEventListener(FormEvents::POST_SUBMIT, function (FormEvent $event) {
/** @var ImapEmailOrigin $data */
$data = $event->getData();
if ($data !== null) {
if ($data->getOwner() === null) {
$data->setOwner($this->securityFacade->getLoggedUser());
}
if ($data->getOrganization() === null) {
$organization = $this->securityFacade->getOrganization() ? $this->securityFacade->getOrganization() : $this->securityFacade->getLoggedUser()->getOrganization();
$data->setOrganization($organization);
}
$event->setData($data);
}
});
}
示例12: getCurrentOrganization
/**
* @return bool|Organization
*/
protected function getCurrentOrganization()
{
$businessUnit = $this->getCurrentBusinessUnit($this->securityFacade->getOrganization());
if (!$businessUnit) {
return true;
}
return $businessUnit->getOrganization();
}
示例13: getUnreadEmailsCount
/**
* Return array of numbers unread emails per folder
*
* @return array
*/
public function getUnreadEmailsCount()
{
$currentOrganization = $this->securityFacade->getOrganization();
$currentUser = $this->securityFacade->getLoggedUser();
$result = $this->em->getRepository("OroEmailBundle:Email")->getCountNewEmailsPerFolders($currentUser, $currentOrganization);
$total = $this->em->getRepository("OroEmailBundle:Email")->getCountNewEmails($currentUser, $currentOrganization);
$result[] = array('num' => $total, 'id' => 0);
return $result;
}
示例14: getChoiceList
/**
* Returns array of mailbox choices.
*
* @return array
*/
public function getChoiceList()
{
$repo = $this->doctrine->getRepository('OroEmailBundle:Mailbox');
/** @var Mailbox[] $systemMailboxes */
$systemMailboxes = $repo->findAvailableMailboxes($this->securityFacade->getLoggedUser(), $this->securityFacade->getOrganization());
$origins = $this->getOriginsList();
$choiceList = [];
foreach ($origins as $origin) {
$mailbox = $origin->getMailboxName();
if (count($origin->getFolders()) > 0) {
$choiceList[$origin->getId()] = str_replace('@', '\\@', $mailbox);
}
}
foreach ($systemMailboxes as $mailbox) {
$choiceList[$mailbox->getOrigin()->getId()] = $mailbox->getLabel();
}
return $choiceList;
}
示例15: ensureCalendarSet
/**
* @param CalendarEvent $entity
*
* @throws \LogicException
*/
protected function ensureCalendarSet(CalendarEvent $entity)
{
if ($entity->getCalendar() || $entity->getSystemCalendar()) {
return;
}
if (!$this->securityFacade->getLoggedUser() || !$this->securityFacade->getOrganization()) {
throw new \LogicException('Both logged in user and organization must be defined.');
}
/** @var Calendar $defaultCalendar */
$defaultCalendar = $this->manager->getRepository('OroCalendarBundle:Calendar')->findDefaultCalendar($this->securityFacade->getLoggedUser()->getId(), $this->securityFacade->getOrganization()->getId());
$entity->setCalendar($defaultCalendar);
}