当前位置: 首页>>代码示例>>PHP>>正文


PHP MauticFactory::getSession方法代码示例

本文整理汇总了PHP中Mautic\CoreBundle\Factory\MauticFactory::getSession方法的典型用法代码示例。如果您正苦于以下问题:PHP MauticFactory::getSession方法的具体用法?PHP MauticFactory::getSession怎么用?PHP MauticFactory::getSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Mautic\CoreBundle\Factory\MauticFactory的用法示例。


在下文中一共展示了MauticFactory::getSession方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getTokenContent

 /**
  * @param int $page
  *
  * @return string
  */
 public function getTokenContent($page = 1)
 {
     if (!$this->factory->getSecurity()->isGranted('lead:fields:full')) {
         return;
     }
     $session = $this->factory->getSession();
     //set limits
     $limit = 5;
     $start = $page === 1 ? 0 : ($page - 1) * $limit;
     if ($start < 0) {
         $start = 0;
     }
     $request = $this->factory->getRequest();
     $search = $request->get('search', $session->get('mautic.lead.emailtoken.filter', ''));
     $session->set('mautic.lead.emailtoken.filter', $search);
     $filter = array('string' => $search, 'force' => array(array('column' => 'f.isPublished', 'expr' => 'eq', 'value' => true)));
     $fields = $this->factory->getModel('lead.field')->getEntities(array('start' => $start, 'limit' => $limit, 'filter' => $filter, 'orderBy' => 'f.label', 'orderByDir' => 'ASC', 'hydration_mode' => 'HYDRATE_ARRAY'));
     $count = count($fields);
     if ($count && $count < $start + 1) {
         //the number of entities are now less then the current page so redirect to the last page
         if ($count === 1) {
             $page = 1;
         } else {
             $page = ceil($count / $limit) ?: 1;
         }
         $session->set('mautic.lead.emailtoken.page', $page);
     }
     return $this->factory->getTemplating()->render('MauticLeadBundle:SubscribedEvents\\EmailToken:list.html.php', array('items' => $fields, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search));
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:34,代码来源:EmailTokenHelper.php

示例2: logout

 /**
  * {@inheritdoc}
  *
  * @param Request $request
  *
  * @return Response never null
  */
 public function logout(Request $request, Response $response, TokenInterface $token)
 {
     /** @var \Mautic\UserBundle\Model\UserModel $userModel */
     $userModel = $this->factory->getModel('user');
     $userModel->setOnlineStatus('offline');
     $dispatcher = $this->factory->getDispatcher();
     if ($dispatcher->hasListeners(UserEvents::USER_LOGOUT)) {
         $event = new LogoutEvent($this->factory);
         $dispatcher->dispatch(UserEvents::USER_LOGOUT, $event);
     }
     // Clear session
     $this->factory->getSession()->clear();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:20,代码来源:LogoutHandler.php

示例3: getTokenContent

 /**
  * @param int   $page
  * @param array $entityArguments
  * @param array $viewParameters
  *
  * @return string
  */
 public function getTokenContent($page = 1, $entityArguments = array(), $viewParameters = array())
 {
     if (is_array($page)) {
         // Laziness
         $entityArguments = $page;
         $page = 1;
     }
     //set some permissions
     $permissions = $this->factory->getSecurity()->isGranted($this->permissionSet, "RETURN_ARRAY");
     if (in_array(false, $permissions)) {
         return;
     }
     $session = $this->factory->getSession();
     //set limits
     $limit = 5;
     $start = $page === 1 ? 0 : ($page - 1) * $limit;
     if ($start < 0) {
         $start = 0;
     }
     $request = $this->factory->getRequest();
     $search = $request->get('search', $session->get('mautic' . $this->langVar . 'buildertoken.filter', ''));
     $session->set('mautic' . $this->langVar . 'buildertoken.filter', $search);
     $model = $this->factory->getModel($this->modelName);
     $repo = $model->getRepository();
     $prefix = $repo->getTableAlias();
     if (!empty($prefix)) {
         $prefix .= '.';
     }
     $filter = array('string' => $search);
     $filter['force'] = isset($entityArguments['filter']['force']) ? $entityArguments['filter']['force'] : array();
     if (isset($permissions[$this->viewPermissionBase . ':viewother']) && !$permissions[$this->viewPermissionBase . ':viewother']) {
         $filter['force'][] = array('column' => $prefix . 'createdBy', 'expr' => 'eq', 'value' => $this->factory->getUser()->getId());
     }
     $entityArguments['filter'] = $filter;
     $entityArguments = array_merge(array('start' => $start, 'limit' => $limit, 'orderByDir' => 'DESC'), $entityArguments);
     $items = $model->getEntities($entityArguments);
     $count = count($items);
     if ($count && $count < $start + 1) {
         //the number of entities are now less then the current page so redirect to the last page
         if ($count === 1) {
             $page = 1;
         } else {
             $page = ceil($count / $limit) ?: 1;
         }
         $session->set('mautic' . $this->langVar . 'buildertoken.page', $page);
     }
     return $this->factory->getTemplating()->render($this->bundleName . ':SubscribedEvents\\BuilderToken:list.html.php', array_merge($viewParameters, array('items' => $items, 'page' => $page, 'limit' => $limit, 'totalCount' => $count, 'tmpl' => $request->get('tmpl', 'index'), 'searchValue' => $search)));
 }
开发者ID:woakes070048,项目名称:mautic,代码行数:55,代码来源:BuilderTokenHelper.php

示例4: buildIcons

 /**
  * Find and add menu items
  *
  * @param MauticEvents\IconEvent $event
  *
  * @return void
  */
 protected function buildIcons(MauticEvents\IconEvent $event)
 {
     $session = $this->factory->getSession();
     $icons = $session->get('mautic.menu.icons', array());
     if (empty($icons)) {
         $bundles = $this->factory->getMauticBundles(true);
         $menuHelper = $this->factory->getHelper('menu');
         foreach ($bundles as $bundle) {
             if (!empty($bundle['config']['menu']['main'])) {
                 $items = !isset($bundle['config']['menu']['main']['items']) ? $bundle['config']['menu']['main'] : $bundle['config']['menu']['main']['items'];
             }
             if (!empty($items)) {
                 $menuHelper->createMenuStructure($items);
                 foreach ($items as $item) {
                     if (isset($item['iconClass']) && isset($item['id'])) {
                         $id = explode('_', $item['id']);
                         if (isset($id[1])) {
                             // some bundle names are in plural, create also singular item
                             if (substr($id[1], -1) == 's') {
                                 $event->addIcon(rtrim($id[1], 's'), $item['iconClass']);
                             }
                             $event->addIcon($id[1], $item['iconClass']);
                         }
                     }
                 }
             }
         }
         unset($bundles, $menuHelper);
         $icons = $event->getIcons();
         $session->set('mautic.menu.icons', $icons);
     } else {
         $event->setIcons($icons);
     }
 }
开发者ID:HomeRefill,项目名称:mautic,代码行数:41,代码来源:CommonSubscriber.php

示例5: extractAuthKeys

 /**
  * Extacts the auth keys from response and saves entity
  *
  * @param $data
  * @param $tokenOverride
  *
  * @return bool|string false if no error; otherwise the error string
  */
 public function extractAuthKeys($data, $tokenOverride = null)
 {
     //check to see if an entity exists
     $entity = $this->getIntegrationSettings();
     if ($entity == null) {
         $entity = new Integration();
         $entity->setName($this->getName());
     }
     // Prepare the keys for extraction such as renaming, setting expiry, etc
     $data = $this->prepareResponseForExtraction($data);
     //parse the response
     $authTokenKey = $tokenOverride ? $tokenOverride : $this->getAuthTokenKey();
     if (is_array($data) && isset($data[$authTokenKey])) {
         $keys = $this->mergeApiKeys($data, null, true);
         $encrypted = $this->encryptApiKeys($keys);
         $entity->setApiKeys($encrypted);
         $this->factory->getSession()->set($this->getName() . '_tokenResponse', $data);
         $error = false;
     } elseif (is_array($data) && isset($data['access_token'])) {
         $this->factory->getSession()->set($this->getName() . '_tokenResponse', $data);
         $error = false;
     } else {
         $error = $this->getErrorsFromResponse($data);
         if (empty($error)) {
             $error = $this->factory->getTranslator()->trans("mautic.integration.error.genericerror", array(), "flashes");
         }
     }
     //save the data
     $em = $this->factory->getEntityManager();
     $em->persist($entity);
     $em->flush();
     $this->setIntegrationSettings($entity);
     return $error;
 }
开发者ID:Yame-,项目名称:mautic,代码行数:42,代码来源:AbstractIntegration.php

示例6: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->validator = $factory->getValidator();
     $this->apiMode = $factory->getRequest()->get('api_mode', $factory->getSession()->get('mautic.client.filter.api_mode', 'oauth1a'));
     $this->router = $factory->getRouter();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:10,代码来源:ClientType.php

示例7: addBrowserNotification

 /**
  * @param        $message
  * @param array  $messageVars
  * @param string $domain
  * @param null   $title
  * @param null   $icon
  * @param bool   $addNotification
  * @param string $type
  */
 public function addBrowserNotification($message, $messageVars = array(), $domain = 'flashes', $title = null, $icon = null, $addNotification = true, $type = 'notice')
 {
     if ($domain == null) {
         $domain = 'flashes';
     }
     $translator = $this->factory->getTranslator();
     if ($domain === false) {
         //message is already translated
         $translatedMessage = $message;
     } else {
         if (isset($messageVars['pluralCount'])) {
             $translatedMessage = $translator->transChoice($message, $messageVars['pluralCount'], $messageVars, $domain);
         } else {
             $translatedMessage = $translator->trans($message, $messageVars, $domain);
         }
     }
     if ($title !== null) {
         $title = $translator->trans($title);
     } else {
         $title = 'Mautic';
     }
     if ($icon == null) {
         $icon = 'media/images/favicon.ico';
     }
     if (strpos($icon, 'http') !== 0) {
         $assetHelper = $this->factory->getHelper('template.assets');
         $icon = $assetHelper->getUrl($icon, null, null, true);
     }
     $session = $this->factory->getSession();
     $browserNotifications = $session->get('mautic.browser.notifications', array());
     $browserNotifications[] = array('message' => $translatedMessage, 'title' => $title, 'icon' => $icon);
     $session->set('mautic.browser.notifications', $browserNotifications);
     if (!defined('MAUTIC_INSTALLER') && $addNotification) {
         switch ($type) {
             case 'warning':
                 $iconClass = "text-warning fa-exclamation-triangle";
                 break;
             case 'error':
                 $iconClass = "text-danger fa-exclamation-circle";
                 break;
             case 'notice':
                 $iconClass = "fa-info-circle";
             default:
                 break;
         }
         //If the user has not interacted with the browser for the last 30 seconds, consider the message unread
         $lastActive = $this->request->get('mauticUserLastActive', 0);
         $isRead = $lastActive > 30 ? 0 : 1;
         $this->addNotification($translatedMessage, null, $isRead, null, $iconClass);
     }
 }
开发者ID:Yame-,项目名称:mautic,代码行数:60,代码来源:CommonController.php

示例8: getAuthLoginUrl

 /**
  * Generate the auth login URL.  Note that if oauth2, response_type=code is assumed.  If this is not the case,
  * override this function.
  *
  * @return string
  */
 public function getAuthLoginUrl()
 {
     $authType = $this->getAuthenticationType();
     if ($authType == 'oauth2') {
         $callback = $this->getAuthCallbackUrl();
         $clientIdKey = $this->getClientIdKey();
         $state = $this->getAuthLoginState();
         $url = $this->getAuthenticationUrl() . '?client_id=' . $this->keys[$clientIdKey] . '&response_type=code' . '&redirect_uri=' . urlencode($callback) . '&state=' . $state;
         if ($scope = $this->getAuthScope()) {
             $url .= '&scope=' . urlencode($scope);
         }
         $this->factory->getSession()->set($this->getName() . '_csrf_token', $state);
         return $url;
     } else {
         return $this->factory->getRouter()->generate('mautic_integration_auth_callback', array('integration' => $this->getName()));
     }
 }
开发者ID:smotalima,项目名称:mautic,代码行数:23,代码来源:AbstractIntegration.php

示例9: __construct

 /**
  * @param MauticFactory $factory
  */
 public function __construct(MauticFactory $factory)
 {
     $this->translator = $factory->getTranslator();
     $this->session = $factory->getSession();
 }
开发者ID:Jandersolutions,项目名称:mautic,代码行数:8,代码来源:CategoryType.php


注:本文中的Mautic\CoreBundle\Factory\MauticFactory::getSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。