本文整理汇总了PHP中Symfony\Component\HttpFoundation\Session\Session::all方法的典型用法代码示例。如果您正苦于以下问题:PHP Session::all方法的具体用法?PHP Session::all怎么用?PHP Session::all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Symfony\Component\HttpFoundation\Session\Session
的用法示例。
在下文中一共展示了Session::all方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: indexAction
/**
* @Route("/", name="homepage")
*/
public function indexAction(Request $request)
{
$session = new Session();
if ($session->isStarted() == true) {
$session->start();
}
$products = $this->getDoctrine()->getRepository('AppBundle:Product')->findAll();
$prodId = $request->request->get('prod', 'noone');
$inBasket[] = "Empty Basket, please select a product";
if ($prodId != 'noone') {
$product = $this->getDoctrine()->getRepository('AppBundle:Product')->find($prodId);
$session->set($product->getId(), $product->getName());
$log = new Log();
$log->setProdName($product->getName());
$log->setDate(new \DateTime());
$em = $this->getDoctrine()->getManager();
$em->persist($log);
$em->flush();
echo "Dev : Log saved to database. Product name - " . $product->getName() . " Current time - " . $log->getDate()->format('H:i:s \\O\\n Y-m-d');
$inBasket = $session->all();
} else {
if ($session->count() != 0) {
$inBasket = $session->all();
echo "Please select a Product before submitting !!!";
}
}
return $this->render('default/index.html.twig', ['products' => $products, 'basketProds' => $inBasket]);
}
示例2: testSetsOnFirstCheck
public function testSetsOnFirstCheck()
{
// Change client ip
$this->request->server->set('REMOTE_ADDR', '111.112.113.114');
$this->request->server->set('HTTP_USER_AGENT', 'TESTING');
// Don't invalidate
$this->session->expects($this->never())->method('invalidate');
$this->validator->handleSessionValidation($this->session);
$this->assertEquals($this->session->all(), array('CLIENT_REMOTE_ADDR' => '111.112.113.114', 'CLIENT_HTTP_USER_AGENT' => 'TESTING'));
}
示例3: getSessionValues
/**
* @return array
*/
public function getSessionValues()
{
$sessionArray = $this->session->all();
$sessionValues = array();
foreach ($sessionArray as $key => $value) {
if (preg_match('@^' . $this->namespace . '@', $key)) {
$shortKey = preg_replace('@^' . $this->namespace . '@', '', $key);
$sessionValues[$shortKey] = $value;
}
}
return $sessionValues;
}
示例4: unsetUpload
/**
* Methode permettant de suprimmer un élement dans les uploads dans la session
*
* @param int $id id de la pièce
*/
public function unsetUpload($id)
{
if (array_key_exists('uploads', $this->session->all())) {
$uploads = $this->session->get('uploads');
$key = array_search(intval($id), $uploads);
if (is_numeric($key)) {
unset($uploads[$key]);
if (empty($uploads)) {
$this->session->remove('uploads');
} else {
$this->session->set('uploads', $uploads);
}
}
}
}
示例5: clearAllPersistentData
/**
* {@inheritDoc}
*/
protected function clearAllPersistentData()
{
foreach ($this->session->all() as $key => $v) {
if (0 !== strpos($key, $this->sessionNamespace)) {
continue;
}
$this->clearPersistentData($key);
}
}
示例6: testThisShouldUnsetUploadWhenMultiple
public function testThisShouldUnsetUploadWhenMultiple()
{
$session = new Session(new MockArraySessionStorage());
//mocking the entity
$stl = $this->getMock('Finortho\\Fritage\\EchangeBundle\\Entity\\Stl');
$stl->expects($this->any())->method('getId')->will($this->returnValue(1));
$stlBis = $this->getMock('Finortho\\Fritage\\EchangeBundle\\Entity\\Stl');
$stlBis->expects($this->any())->method('getId')->will($this->returnValue(2));
$sessionHandler = new SessionHandler($session, $this->em);
$sessionHandler->setUploads($stl);
$sessionHandler->setUploads($stlBis);
$sessionHandler->unsetUpload(1);
$this->assertEquals(count($session->all()), 1);
}
示例7: loadAjaxDataAction
/**
* Ausgabe der durch Filtern übergebene Liste
*
* @param object $request Request von der vorhergehenden Seite
*
* @return html Ausgabe des Schnippsels
*/
public function loadAjaxDataAction(Request $request)
{
$req = $request->request->get('ajax');
if (!empty($req)) {
switch ($request->request->get('ajax')) {
case "transactions":
$value = $request->request->get('value');
if ($request->request->get('filter') == "t.starttimestamp" || $request->request->get('filter') == "t.stoptimestamp") {
$value = HelpController::formatDate($value);
}
$session_filter = new Session();
$session_filter->start();
if ($value != "*") {
$session_filter->set($request->request->get('filter'), $value);
} else {
$session_filter->remove($request->request->get('filter'));
}
$array_filter = array($request->request->get('filter') => $value);
$transactions = $this->getDoctrine()->getRepository('SteveFrontendBundle:Transaction')->getTransaction($session_filter->all());
$array_render = array('transactions' => $transactions);
$template = $this->renderView("SteveFrontendBundle:Ajax:listtransactions.html.twig", $array_render);
break;
case "users":
$users = $this->getDoctrine()->getRepository('SteveFrontendBundle:User')->findAll();
$array_render = array('users' => $users);
$template = $this->renderView("SteveFrontendBundle:Ajax:listuser.html.twig", $array_render);
break;
case "chargepoint":
/* setzt bzw. Update eventuell hier noch verschieben */
$transaction_id = $request->request->get('transaction_id');
$chargeBoxId = $request->request->get('chargeBoxId');
$chargebox = $this->getDoctrine()->getRepository('SteveFrontendBundle:Chargebox')->find($chargeBoxId);
$em = $this->getDoctrine()->getManager();
$transactions = $em->getRepository('SteveFrontendBundle:Transaction')->find($transaction_id);
if (!$transactions) {
throw $this->createNotFoundException('No Transfer found for id ' . $transaction_id);
}
$now = new DateTime("now");
$transactions->setStopvalue($transactions->getStartvalue());
$transactions->setStoptimestamp($now);
$em->flush();
$array_render = OutputController::createContentChargebox(null, $chargeBoxId);
$template = $this->renderView('SteveFrontendBundle:Ajax:listchargebox.html.twig', $array_render);
break;
default:
break;
}
}
return new Response($template);
}
示例8: testHandleGatewayWithCheckOnceSuccess
/**
* Test processing gateway with CHECK_ONCE to make sure SESSION gets set.
*
* @covers ::handle
* @covers ::handleGateway
*/
public function testHandleGatewayWithCheckOnceSuccess()
{
$config_factory = $this->getConfigFactoryStub(array('cas.settings' => array('forced_login.enabled' => FALSE, 'gateway.check_frequency' => CasHelper::CHECK_ONCE, 'gateway.paths' => array('<front>'))));
$cas_subscriber = $this->getMockBuilder('\\Drupal\\cas\\Subscriber\\CasSubscriber')->setConstructorArgs(array($this->requestStack, $this->routeMatcher, $config_factory, $this->currentUser, $this->conditionManager, $this->casHelper))->setMethods(NULL)->getMock();
$this->event->expects($this->any())->method('getRequestType')->will($this->returnValue(HttpKernelInterface::MASTER_REQUEST));
$request_object = $this->getMock('\\Symfony\\Component\\HttpFoundation\\Request');
$attributes = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ParameterBag');
$request_object->attributes = $attributes;
$server = $this->getMock('\\Symfony\\Component\\HttpFoundation\\ServerBag');
$request_object->server = $server;
$request_object->expects($this->any())->method('getSession')->will($this->returnValue($this->session));
$condition = $this->getMockBuilder('\\Drupal\\Core\\Condition\\ConditionPluginBase')->disableOriginalConstructor()->getMock();
$this->conditionManager->expects($this->any())->method('createInstance')->with('request_path')->will($this->returnValue($condition));
$condition->expects($this->any())->method('setConfiguration')->with(array('<front>'));
$this->conditionManager->expects($this->any())->method('execute')->with($condition)->will($this->returnValue(true));
$request_object->expects($this->once())->method('isMethod')->with('GET')->will($this->returnValue(TRUE));
$this->requestStack->expects($this->any())->method('getCurrentRequest')->will($this->returnValue($request_object));
$this->casHelper->expects($this->once())->method('getServerLoginUrl')->will($this->returnValue('https://example.com'));
$this->event->expects($this->once())->method('setResponse');
$cas_subscriber->handle($this->event);
$this->assertArrayHasKey('cas_gateway_checked', $this->session->all());
}
示例9: Session
return $error;
}
if (!isset($fields['email']) || empty($fields['email'])) {
$fields['email'] = "{$mobile_number}@163.com";
}
$session = new Session();
$session->start();
if ($session->has($mobile_number)) {
$info = $session->get($mobile_number);
if ($fields['code'] != $info['code']) {
$error['message'] = '验证码不正确';
return $error;
}
} else {
$error['message'] = '没有相关' . $mobile_number . '的验证码';
$error['session_info'] = $session->all();
return $error;
}
$user = ServiceKernel::instance()->createService('User.UserService')->register($fields);
return $user;
});
$api->get('/send/SMS', function (Request $request) {
$message = array();
$time_len = 60;
$mobile_number = $request->query->get('mobile_number');
// $UserService = ServiceKernel::instance()->createService('User.UserService');
// $user = $UserService->getUserByNickname($mobile_number);
// if (!empty($user)) {
$session = $request->getSession();
$session = new Session();
$session->start();