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


PHP SessionInterface::save方法代码示例

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


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

示例1:

 function it_logs_user_out(SessionInterface $session, CookieSetterInterface $cookieSetter)
 {
     $session->set('_security_shop', null)->shouldBeCalled();
     $session->save()->shouldBeCalled();
     $session->getName()->willReturn('MOCKEDSID');
     $session->getId()->willReturn('xyzc123');
     $cookieSetter->setCookie('MOCKEDSID', 'xyzc123')->shouldBeCalled();
     $this->logOut();
 }
开发者ID:loic425,项目名称:Sylius,代码行数:9,代码来源:SecurityServiceSpec.php

示例2: 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

示例3: 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

示例4: onResponse

 /**
  * Add the session cookie to the response if it is started.
  *
  * @param FilterResponseEvent $event
  */
 public function onResponse(FilterResponseEvent $event)
 {
     if (!$event->isMasterRequest() || !$this->session->isStarted()) {
         return;
     }
     $this->session->save();
     $cookie = $this->generateCookie();
     $event->getResponse()->headers->setCookie($cookie);
 }
开发者ID:nbehier,项目名称:bolt,代码行数:14,代码来源:SessionListener.php

示例5: handle

 /**
  * @inheritDoc
  */
 public function handle(Request $request, $type = self::MASTER_REQUEST, $catch = true)
 {
     $this->startSession($request);
     $request->setSession($this->session);
     $response = $this->wrapped->handle($request, $type, $catch);
     $this->session->save();
     $this->writeSessionTo($response);
     return $response;
 }
开发者ID:fluxbb,项目名称:core,代码行数:12,代码来源:SessionKernel.php

示例6: logIn

 /**
  * {@inheritdoc}
  */
 public function logIn($email, $providerKey, Session $minkSession)
 {
     $user = $this->userRepository->findOneBy(['username' => $email]);
     if (null === $user) {
         throw new \InvalidArgumentException(sprintf('There is no user with email %s', $email));
     }
     $token = new UsernamePasswordToken($user, $user->getPassword(), $providerKey, $user->getRoles());
     $this->session->set('_security_user', serialize($token));
     $this->session->save();
     $minkSession->setCookie($this->session->getName(), $this->session->getId());
 }
开发者ID:Mangetsu,项目名称:Sylius,代码行数:14,代码来源:SecurityService.php

示例7: sendContent

 /**
  * {@inheritdoc}
  */
 public function sendContent($content, array $attachments)
 {
     // First, gather the BigPipe placeholders that must be replaced.
     $placeholders = isset($attachments['big_pipe_placeholders']) ? $attachments['big_pipe_placeholders'] : [];
     $nojs_placeholders = isset($attachments['big_pipe_nojs_placeholders']) ? $attachments['big_pipe_nojs_placeholders'] : [];
     // BigPipe sends responses using "Transfer-Encoding: chunked". To avoid
     // sending already-sent assets, it is necessary to track cumulative assets
     // from all previously rendered/sent chunks.
     // @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.41
     $cumulative_assets = AttachedAssets::createFromRenderArray(['#attached' => $attachments]);
     $cumulative_assets->setAlreadyLoadedLibraries($attachments['library']);
     // The content in the placeholders may depend on the session, and by the
     // time the response is sent (see index.php), the session is already closed.
     // Reopen it for the duration that we are rendering placeholders.
     $this->session->start();
     // Find the closing </body> tag and get the strings before and after. But be
     // careful to use the latest occurrence of the string "</body>", to ensure
     // that strings in inline JavaScript or CDATA sections aren't used instead.
     $parts = explode('</body>', $content);
     $post_body = array_pop($parts);
     $pre_body = implode('', $parts);
     $this->sendPreBody($pre_body, $nojs_placeholders, $cumulative_assets);
     $this->sendPlaceholders($placeholders, $this->getPlaceholderOrder($pre_body, $placeholders), $cumulative_assets);
     $this->sendPostBody($post_body);
     // Close the session again.
     $this->session->save();
     return $this;
 }
开发者ID:eigentor,项目名称:tommiblog,代码行数:31,代码来源:BigPipe.php

示例8: 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

示例9: closeSession

 protected function closeSession(Request $request, Response $response)
 {
     // save all session data
     $this->session->save();
     // attach the session cookie
     $response->headers->setCookie($this->makeCookie($request));
 }
开发者ID:autarky,项目名称:framework,代码行数:7,代码来源:SessionMiddleware.php

示例10:

 function it_does_not_log_user_in_if_user_was_not_found(UserRepositoryInterface $userRepository, SessionInterface $session, CookieSetterInterface $cookieSetter)
 {
     $userRepository->findOneBy(['username' => 'sylius@example.com'])->willReturn(null);
     $session->set(Argument::cetera())->shouldNotBeCalled();
     $session->save()->shouldNotBeCalled();
     $cookieSetter->setCookie(Argument::cetera())->shouldNotBeCalled();
     $this->shouldThrow(new \InvalidArgumentException(sprintf('There is no user with email sylius@example.com')))->during('logIn', ['sylius@example.com']);
 }
开发者ID:TeamNovatek,项目名称:Sylius,代码行数:8,代码来源:SecurityServiceSpec.php

示例11: buildView

 /**
  * {@inheritdoc}
  */
 public function buildView(FormView $view, FormInterface $form, array $options)
 {
     if (null !== $options['crop_by_ratio'] && null !== $options['crop_by_size'] && true === (bool) $options['allow_crop']) {
         throw new \InvalidArgumentException('Multiple crop strategies at the same field are not allowed.');
     }
     if (null !== $options['crop_by_size'] && (!is_array($options['crop_by_size']) || !isset($options['crop_by_size']['w']) || !isset($options['crop_by_size']['h']))) {
         throw new \InvalidArgumentException('crop_by_size requires array [w => [int], h => [int]].');
     }
     $uniqueKey = md5(microtime() . rand());
     $sessionData = array('handler' => $options['handler'], 'imagine_filter' => $options['imagine_filter'], 'options' => array('accept_file_type' => $options['accept_file_type'], 'allow_multiple' => $options['allow_multiple'], 'allow_crop' => $options['allow_crop'], 'crop_by_size' => $options['crop_by_size'], 'crop_by_ratio' => $options['crop_by_ratio']), 'handler_options' => array('save_path' => $options['save_path'], 'web_path' => $options['web_path']));
     $this->session->set($uniqueKey, $sessionData);
     $this->session->save();
     $view->vars['unique_key'] = $uniqueKey;
     $view->vars['imagine_filter'] = $options['imagine_filter'];
     $view->vars['allow_crop'] = $options['allow_crop'];
     $view->vars['crop_by_ratio'] = $options['crop_by_ratio'];
     $view->vars['crop_by_size'] = $options['crop_by_size'];
 }
开发者ID:acin91,项目名称:ZmcImageBundle,代码行数:21,代码来源:FileUploadHiddenType.php

示例12: login

 /**
  * @param BaseUser $user
  * @param SessionInterface $session
  * @param $firewall
  * @throws UnsupportedDriverActionException
  */
 public function login(BaseUser $user, SessionInterface $session, $firewall)
 {
     $driver = $this->getDriver();
     if (!$driver instanceof BrowserKitDriver) {
         //Fall back to manual login if BrowserKitDriver is not used
         throw new UnsupportedDriverActionException("Not supported by the current driver", $driver);
     }
     $client = $driver->getClient();
     $client->getCookieJar()->set(new Cookie(session_name(), true));
     $token = new UsernamePasswordToken($user, null, $firewall, $user->getRoles());
     $session->set('_security_' . $firewall, serialize($token));
     $session->save();
     $cookie = new Cookie($session->getName(), $session->getId());
     $client->getCookieJar()->set($cookie);
 }
开发者ID:vivait,项目名称:user-bundle,代码行数:21,代码来源:Login.php

示例13: sendContent

 /**
  * {@inheritdoc}
  */
 public function sendContent($content, array $attachments)
 {
     // First, gather the BigPipe placeholders that must be replaced.
     $placeholders = isset($attachments['big_pipe_placeholders']) ? $attachments['big_pipe_placeholders'] : [];
     $nojs_placeholders = isset($attachments['big_pipe_nojs_placeholders']) ? $attachments['big_pipe_nojs_placeholders'] : [];
     // BigPipe sends responses using "Transfer-Encoding: chunked". To avoid
     // sending already-sent assets, it is necessary to track cumulative assets
     // from all previously rendered/sent chunks.
     // @see http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.41
     $cumulative_assets = AttachedAssets::createFromRenderArray(['#attached' => $attachments]);
     $cumulative_assets->setAlreadyLoadedLibraries(explode(',', $attachments['drupalSettings']['ajaxPageState']['libraries']));
     // The content in the placeholders may depend on the session, and by the
     // time the response is sent (see index.php), the session is already closed.
     // Reopen it for the duration that we are rendering placeholders.
     $this->session->start();
     list($pre_body, $post_body) = explode('</body>', $content, 2);
     $this->sendPreBody($pre_body, $nojs_placeholders, $cumulative_assets);
     $this->sendPlaceholders($placeholders, $this->getPlaceholderOrder($pre_body), $cumulative_assets);
     $this->sendPostBody($post_body);
     // Close the session again.
     $this->session->save();
     return $this;
 }
开发者ID:DrupalTV,项目名称:DrupalTV,代码行数:26,代码来源:BigPipe.php

示例14: testSave

 public function testSave()
 {
     $this->session->start();
     $this->session->save();
 }
开发者ID:manhvu1212,项目名称:videoplatform,代码行数:5,代码来源:SessionTest.php

示例15: setSerializedToken

 /**
  * @param string $token
  */
 private function setSerializedToken($token)
 {
     $this->session->set($this->sessionTokenVariable, $token);
     $this->session->save();
 }
开发者ID:okwinza,项目名称:Sylius,代码行数:8,代码来源:SecurityService.php


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