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


PHP SessionInterface::set方法代码示例

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


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

示例1: save

 /**
  * Save the translations in the session
  *
  * @param Translations $translations
  * @param string       $key
  * @return bool
  */
 public function save(Translations $translations, $key = self::DEFAULT_KEY)
 {
     $rawTranslations = $translations->getRawData();
     $this->session->set($key, $rawTranslations);
     $this->session->save();
     return true;
 }
开发者ID:davamigo,项目名称:translator-bundle,代码行数:14,代码来源:SessionStorage.php

示例2: markSkipped

 /**
  * @param Task $task
  */
 private function markSkipped(Task $task)
 {
     if (!$this->session instanceof SessionInterface) {
         return;
     }
     $this->session->set($this->getSessionKey($task), true);
 }
开发者ID:redelivre,项目名称:login-cidadao,代码行数:10,代码来源:TasksManager.php

示例3: setToken

 /**
  * @param TokenInterface $token
  */
 private function setToken(TokenInterface $token)
 {
     $serializedToken = serialize($token);
     $this->session->set($this->sessionTokenVariable, $serializedToken);
     $this->session->save();
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:SecurityService.php

示例4: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $clientId = $session->get('client/id');
     $session->set('selected_product_id', -1);
     $menuSelectedCategory = 'general_overview';
     $timezoneData = explode("/", $session->get('client/settings/timezone'));
     $timezoneContinent = $timezoneData[0];
     $timeZoneContinents = array('Africa' => 1, 'America' => 2, 'Antarctica' => 4, 'Arctic' => 8, 'Asia' => 16, 'Atlantic' => 32, 'Australia' => 64, 'Europe' => 128, 'Indian' => 256, 'Pacific' => 512);
     $timeZoneCountry = $timezoneData[1];
     $clientSettings = $this->getRepository(UbirimiClient::class)->getSettings($clientId);
     $client = $this->getRepository(UbirimiClient::class)->getById($clientId);
     if ($request->request->has('update_configuration')) {
         $language = Util::cleanRegularInputField($request->request->get('language'));
         $timezone = Util::cleanRegularInputField($request->request->get('zone'));
         $titleName = Util::cleanRegularInputField($request->request->get('title_name'));
         $operatingMode = Util::cleanRegularInputField($request->request->get('mode'));
         $parameters = array(array('field' => 'title_name', 'value' => $titleName, 'type' => 's'), array('field' => 'operating_mode', 'value' => $operatingMode, 'type' => 's'), array('field' => 'language', 'value' => $language, 'type' => 's'), array('field' => 'timezone', 'value' => $timezone, 'type' => 's'));
         $this->getRepository(UbirimiClient::class)->updateProductSettings($clientId, 'client_settings', $parameters);
         $session->set('client/settings/language', $language);
         $session->set('client/settings/timezone', $timezone);
         return new RedirectResponse('/general-settings/view-general');
     }
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / GeneralSettings Settings / Update';
     return $this->render(__DIR__ . '/../Resources/views/EditSettings.php', get_defined_vars());
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:26,代码来源:EditSettingsController.php

示例5: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $smtpServerId = $request->get('id');
     $smtpServer = $this->getRepository(SMTPServer::class)->getById($smtpServerId);
     $session->set('selected_product_id', -1);
     $menuSelectedCategory = 'general_mail';
     $emptyName = false;
     $emptyFromAddress = false;
     $emptyEmailPrefix = false;
     $emptyHostname = false;
     if ($request->request->has('edit_smtp')) {
         $name = Util::cleanRegularInputField($request->request->get('name'));
         $description = Util::cleanRegularInputField($request->request->get('description'));
         $fromAddress = Util::cleanRegularInputField($request->request->get('from_address'));
         $emailPrefix = Util::cleanRegularInputField($request->request->get('email_prefix'));
         $protocol = Util::cleanRegularInputField($request->request->get('protocol'));
         $hostname = Util::cleanRegularInputField($request->request->get('hostname'));
         $port = Util::cleanRegularInputField($request->request->get('port'));
         $timeout = Util::cleanRegularInputField($request->request->get('timeout'));
         $tls = $request->request->has('tls') ? 1 : 0;
         $username = Util::cleanRegularInputField($request->request->get('username'));
         $password = Util::cleanRegularInputField($request->request->get('password'));
         $date = Util::getServerCurrentDateTime();
         $this->getRepository(SMTPServer::class)->updateById($smtpServerId, $name, $description, $fromAddress, $emailPrefix, $protocol, $hostname, $port, $timeout, $tls, $username, $password, $date);
         $this->getLogger()->addInfo('UPDATE SMTP Server ' . $name, $this->getLoggerContext());
         $session->set('client/settings/smtp', $this->getRepository(SMTPServer::class)->getById($smtpServerId));
         return new RedirectResponse('/general-settings/smtp-settings');
     }
     $sectionPageTitle = $session->get('client/settings/title_name') . ' / GeneralSettings Settings / Update SMTP Server Settings';
     return $this->render(__DIR__ . '/../../Resources/views/smtp/Edit.php', get_defined_vars());
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:32,代码来源:EditController.php

示例6: indexAction

 public function indexAction(Request $request, SessionInterface $session)
 {
     Util::checkUserIsLoggedInAndRedirect();
     $menuSelectedCategory = 'system';
     $timeTrackingFlag = $session->get('yongo/settings/time_tracking_flag');
     $defaultTimeTracking = null;
     switch ($session->get('yongo/settings/time_tracking_default_unit')) {
         case 'w':
             $defaultTimeTracking = 'week';
             break;
         case 'd':
             $defaultTimeTracking = 'day';
             break;
         case 'h':
             $defaultTimeTracking = 'hours';
             break;
         case 'm':
             $defaultTimeTracking = 'minute';
             break;
     }
     if ($request->request->has('edit_time_tracking')) {
         $hoursPerDay = $request->request->get('hours_per_day');
         $daysPerWeek = $request->request->get('days_per_week');
         $defaultUnit = $request->request->get('default_unit');
         $this->getRepository(UbirimiClient::class)->updateTimeTrackingSettings($session->get('client/id'), $hoursPerDay, $daysPerWeek, $defaultUnit);
         $this->getLogger()->addInfo('UPDATE Yongo Time Tracking Settings', $this->getLoggerContext());
         $session->set('yongo/settings/time_tracking_hours_per_day', $hoursPerDay);
         $session->set('yongo/settings/time_tracking_days_per_week', $daysPerWeek);
         $session->set('yongo/settings/time_tracking_default_unit', $defaultUnit);
         return new RedirectResponse('/yongo/administration/issue-features/time-tracking');
     }
     return $this->render(__DIR__ . '/../../../../Resources/views/administration/issue/time_tracking/Edit.php', get_defined_vars());
 }
开发者ID:spiasecki,项目名称:ubirimi,代码行数:33,代码来源:EditController.php

示例7: storeDateTimeSettingsInSession

 /**
  * Make user date and time settings sticky
  *
  * @param UserInterface $user
  * @param SessionInterface $session
  */
 protected function storeDateTimeSettingsInSession(UserInterface $user, SessionInterface $session)
 {
     $session->set('campaignchain.locale', $user->getLocale());
     $session->set('campaignchain.timezone', $user->getTimezone());
     $session->set('campaignchain.dateFormat', $user->getDateFormat());
     $session->set('campaignchain.timeFormat', $user->getTimeFormat());
 }
开发者ID:CampaignChain,项目名称:core,代码行数:13,代码来源:UserDateTimeListener.php

示例8: buildView

 /**
  * @param \Symfony\Component\Form\FormView $view
  * @param \Symfony\Component\Form\FormInterface $form
  * @param array $options
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if ($options['reload'] && !$options['as_url']) {
         throw new \InvalidArgumentException('GregwarCaptcha: The reload option cannot be set without as_url, see the README for more information');
     }
     $sessionKey = sprintf('gcb_%s', $form->getName());
     $isHuman = false;
     if ($options['humanity'] > 0) {
         $humanityKey = sprintf('%s_humanity', $sessionKey);
         if ($this->session->get($humanityKey, 0) > 0) {
             $isHuman = true;
         }
     }
     if ($options['as_url']) {
         $keys = $this->session->get($options['whitelist_key'], array());
         if (!in_array($sessionKey, $keys)) {
             $keys[] = $sessionKey;
         }
         $this->session->set($options['whitelist_key'], $keys);
         $options['session_key'] = $sessionKey;
     }
     $view->vars = array_merge($view->vars, array('captcha_width' => $options['width'], 'captcha_height' => $options['height'], 'reload' => $options['reload'], 'image_id' => uniqid('captcha_'), 'captcha_code' => $this->generator->getCaptchaCode($options), 'value' => '', 'is_human' => $isHuman));
     $persistOptions = array();
     foreach (array('phrase', 'width', 'height', 'distortion', 'length', 'quality', 'background_color', 'text_color') as $key) {
         $persistOptions[$key] = $options[$key];
     }
     $this->session->set($sessionKey, $persistOptions);
 }
开发者ID:BaudouinW,项目名称:Aion-Rising-Back-end,代码行数:33,代码来源:CaptchaType.php

示例9: setToken

 /**
  * {@inheritdoc}
  */
 public function setToken($tokenId, $token)
 {
     if (!$this->session->isStarted()) {
         $this->session->start();
     }
     $this->session->set($this->namespace . '/' . $tokenId, (string) $token);
 }
开发者ID:ayoah,项目名称:symfony,代码行数:10,代码来源:SessionTokenStorage.php

示例10: logInUser

 /**
  * @param UserInterface $user
  */
 private function logInUser(UserInterface $user)
 {
     $token = new UsernamePasswordToken($user, $user->getPassword(), 'randomstringbutnotnull', $user->getRoles());
     $this->session->set($this->sessionTokenVariable, serialize($token));
     $this->session->save();
     $this->cookieSetter->setCookie($this->session->getName(), $this->session->getId());
 }
开发者ID:Mozan,项目名称:Sylius,代码行数:10,代码来源:SecurityService.php

示例11: onCheckoutComplete

 /**
  * {@inheritdoc}
  */
 public function onCheckoutComplete(GenericEvent $event)
 {
     /** @var OrderInterface $order */
     $order = $event->getSubject();
     Assert::isInstanceOf($order, OrderInterface::class);
     $this->session->set('sylius_order_id', $order->getId());
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:CheckoutCompleteListener.php

示例12: set

 /**
  * Set Cart in session
  *
  * @param CartInterface $cart Cart
  *
  * @return $this Self object
  */
 public function set(CartInterface $cart)
 {
     if (!$this->saveInSession) {
         return $this;
     }
     $this->session->set($this->sessionFieldName, $cart->getId());
     return $this;
 }
开发者ID:raizeta,项目名称:elcodi,代码行数:15,代码来源:CartSessionManager.php

示例13: loadUserByOAuthUserResponse

 /**
  * {@inheritdoc}
  */
 public function loadUserByOAuthUserResponse(UserResponseInterface $response)
 {
     $authProviderName = $response->getResourceOwner()->getName();
     $username = $response->getResponse()['login'];
     $this->session->set('owner', $authProviderName);
     $this->session->set('username', $username);
     return $this->loadUserByUsername($username);
 }
开发者ID:ramondelafuente,项目名称:haphpy-birthday,代码行数:11,代码来源:UserProvider.php

示例14: onLogin

 /**
  * Wordpress user login hook method
  *
  * @param WordpressEvent $event
  *
  * @see http://codex.wordpress.org/Plugin_API/Action_Reference/wp_login
  */
 public function onLogin(WordpressEvent $event)
 {
     $wpUser = $event->getParameter('user');
     $user = $this->userManager->find($wpUser->data->ID);
     $user->setWordpressRoles($wpUser->roles);
     $token = new UsernamePasswordToken($user, $user->getPass(), 'secured_area', $user->getRoles());
     $this->securityContext->setToken($token);
     $this->session->set('token', $token);
 }
开发者ID:carboncreative,项目名称:EkinoWordpressBundle,代码行数:16,代码来源:UserHookListener.php

示例15: getId

 /**
  * {@inheritdoc}
  */
 protected function getId($create = TRUE)
 {
     if ($this->currentUser->isAuthenticated()) {
         return $this->currentUser->id();
     } elseif (!$this->session->has('uc_cart_id') && $create) {
         $this->session->set('uc_cart_id', md5(uniqid(rand(), TRUE)));
     }
     return $this->session->has('uc_cart_id') ? $this->session->get('uc_cart_id') : FALSE;
 }
开发者ID:justincletus,项目名称:webdrupalpro,代码行数:12,代码来源:CartManager.php


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