Beispiel #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();
 }
Beispiel #2
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);
     }
 }