Beispiel #1
0
 public function testUpdate()
 {
     $testEntity = SessionTest::createTestSession();
     self::$entityManager->persist($testEntity);
     self::$entityManager->flush();
     $this->assertNotEquals('fubar', $testEntity->getName());
     $testEntity->setName('fubar');
     SessionService::update();
     $entities = self::$entityManager->createQuery('SELECT e FROM Rexmac\\Zyndax\\Entity\\Session e')->execute();
     $this->assertEquals('fubar', $entities[0]->getName());
 }
Beispiel #2
0
 /**
  * Write Session - commit data to resource
  *
  * @param string $id
  * @param string $data
  * @return bool
  */
 public function write($id, $data)
 {
     $data = (string) $data;
     if (null !== ($session = SessionService::find($id))) {
         $session->setModified(time())->setData($data);
         SessionService::update();
         return true;
     }
     SessionService::create(new $this->entityClass(array('id' => $id, 'modified' => time(), 'lifetime' => $this->lifetime, 'data' => $data)));
     return true;
 }