Exemple #1
0
 /**
  * Set variable 
  * 
  * @param string $name  Variable name
  * @param mixed  $value Variable value
  *  
  * @return void
  */
 public function setVar($name, $value)
 {
     $entity = $this->findOneBy(array('name' => $name));
     if (!$entity) {
         $entity = new \XLite\Model\TmpVar();
         $entity->setName($name);
         \XLite\Core\Database::getEM()->persist($entity);
     }
     if (!is_scalar($value)) {
         $value = serialize($value);
     }
     $entity->setValue($value);
     \XLite\Core\Database::getEM()->flush();
 }
Exemple #2
0
 public function testRemove()
 {
     foreach (\XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->findAll() as $c) {
         \XLite\Core\Database::getEM()->remove($c);
     }
     \XLite\Core\Database::getEM()->flush();
     $c = new \XLite\Model\TmpVar();
     $c->map($this->entityData);
     \XLite\Core\Database::getEM()->persist($c);
     \XLite\Core\Database::getEM()->flush();
     $id = $c->getId();
     \XLite\Core\Database::getEM()->remove($c);
     \XLite\Core\Database::getEM()->flush();
     \XLite\Core\Database::getEM()->clear();
     $c = \XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->find($id);
     $this->assertTrue(is_null($c), 'check entity');
     //\XLite\Core\Database::getEM()->remove($c);
     \XLite\Core\Database::getEM()->flush();
 }
Exemple #3
0
 /**
  * Redeclare queue 
  * 
  * @param string $name Queue name
  *  
  * @return void
  */
 public function redeclareQueue($name)
 {
     $key = 'amqp.queue.' . $name;
     $entity = \XLite\Core\Database::getRepo('XLite\\Model\\TmpVar')->findOneBy(array('name' => $key));
     $time = \XLite\Core\Converter::time();
     if (!$entity) {
         $entity = new \XLite\Model\TmpVar();
         $entity->setName($key);
         $entity->setValue($time);
         \XLite\Core\Database::getEM()->persist($entity);
         $this->declareQueue($name);
     } elseif ($entity->getValue() + static::REDECLARE_TTL < $time) {
         $entity->setValue($time);
         $this->declareQueue($name);
     }
 }