Example #1
0
 /**
  * Restart session
  *
  * @return void
  */
 public function restart()
 {
     $this->lastFormId = null;
     $dump = $this->isDump();
     if (!$dump && !\XLite\Core\Database::getEM()->contains($this->session)) {
         try {
             $this->session = \XLite\Core\Database::getEM()->merge($this->session);
         } catch (\Doctrine\ORM\EntityNotFoundException $exception) {
             $this->session = null;
         }
     }
     $old = null;
     if ($this->session) {
         $old = $this->session;
         $oldId = $this->session->getId();
     }
     $this->createSession();
     if ($old && !$dump) {
         // Copy session cells from old to new session
         foreach ($old->getCellsCache() as $cell) {
             $cell->detach();
             $cell->setSession($this->session);
             $this->session->addCells($cell);
             \XLite\Core\Database::getEM()->persist($cell);
         }
         // Remove old session
         \XLite\Core\Database::getEM()->remove($old);
         \XLite\Core\Database::getEM()->flush();
     }
     $this->setCookie();
 }
 /**
  * {@inheritDoc}
  */
 public function addCells(\XLite\Model\SessionCell $cells)
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'addCells', array($cells));
     return parent::addCells($cells);
 }