set() public method

Sets an attribute.
public set ( string $name, mixed $value )
$name string
$value mixed
 /**
  * On kernel response event
  *
  * @param FilterResponseEvent $event
  */
 public function onKernelResponse(FilterResponseEvent $event)
 {
     // Only master request and 200 OK are processed
     if (HttpKernelInterface::MASTER_REQUEST === $event->getRequestType() && $event->getResponse()->isOk()) {
         $route = $this->router->match($this->request->getPathInfo());
         // Ignore internal route
         if (0 === stripos($route['_route'], '_')) {
             return;
         }
         $this->session->set('_unifik.last_master_request_uri', $this->request->getUri());
         $this->session->set('_unifik.last_master_request_route', $route);
     }
 }
 public function set($state, $value)
 {
     if (!in_array($state, array_keys($this->states))) {
         throw new \RunTimeException("Requested state {$state} does not exist");
     }
     $this->session->set($this->prefix . '.' . $state, $value);
 }
    protected function runSessionOnKernelResponse($newToken, $original = null)
    {
        $session = new Session(new ArraySessionStorage());

        if ($original !== null) {
            $session->set('_security_session', $original);
        }

        $this->securityContext->setToken($newToken);

        $request = new Request();
        $request->setSession($session);

        $event = new FilterResponseEvent(
            $this->getMock('Symfony\Component\HttpKernel\HttpKernelInterface'),
            $request,
            HttpKernelInterface::MASTER_REQUEST,
            new Response()
        );

        $listener = new ContextListener($this->securityContext, array(), 'session');
        $listener->onKernelResponse($event);

        return $session;
    }
 public function setUp()
 {
     $this->request = new Request();
     $session = new Session(new ArraySessionStorage());
     $session->set('foobar', 'bar');
     $session->setFlash('foo', 'bar');
     $this->request->setSession($session);
 }
Example #5
0
 public function finishView(FormView $view, FormInterface $form, array $options)
 {
     $configs = array_merge($options['configs'], array('id' => $view->vars['id'], 'name_id' => $view->getChild('name')->vars['id'], 'original_name_id' => $view->getChild('originalName')->vars['id'], 'size_id' => $view->getChild('size')->vars['id'], 'title_id' => $view->getChild('title')->vars['id'], 'caption_id' => $view->getChild('caption')->vars['id'], 'description_id' => $view->getChild('description')->vars['id'], 'hash_id' => $view->getChild('hash')->vars['id'], 'enabled_id' => $view->getChild('enabled')->vars['id'], 'scheduled_for_deletion_id' => $view->getChild('scheduledForDeletion')->vars['id'], 'enabled_value' => false));
     $file = $form->getData();
     if ($file instanceof FileInterface && null !== $file->getId()) {
         $configs['enabled_value'] = $file->isEnabled();
     }
     $this->session->set($view->vars['id'], $configs);
     $view->vars['configs'] = $configs;
 }
 protected function updateSession($translations)
 {
     foreach ($translations as $locale => $values) {
         // Clear empty domains
         foreach (array('new', 'updated') as $modififactionType) {
             foreach ($values[$modififactionType] as $domain => $trads) {
                 if (count($trads) == 0) {
                     unset($translations[$locale][$modififactionType][$domain]);
                 }
             }
         }
         // Clear empty locales
         if (count($translations[$locale]['new']) == 0 && count($translations[$locale]['updated']) == 0) {
             unset($translations[$locale]);
         }
     }
     $this->session->set(Configuration::SESSION_PREFIX . 'import-list', $translations);
 }
Example #7
0
 private function generateCaptchaValue()
 {
     if (!$this->keepValue || !$this->session->has($this->key)) {
         $value = '';
         $chars = str_split($this->charset);
         for ($i = 0; $i < $this->length; $i++) {
             $value .= $chars[array_rand($chars)];
         }
         $this->session->set($this->key, $value);
     } else {
         $value = $this->session->get($this->key);
     }
     return $value;
 }
 /**
  * Clear the current filters
  */
 public function resetFilters()
 {
     $this->session->set(Configuration::SESSION_PREFIX . 'filters', null);
 }