예제 #1
0
 public function testSetGetMode()
 {
     $this->object->setMode(Variant::MODE_INSTANT);
     $this->assertEquals(Variant::MODE_INSTANT, $this->object->getMode());
 }
예제 #2
0
 /**
  * {@inheritDoc}
  */
 public static function fromArray($array)
 {
     $variant = new Variant();
     if (isset($array['name'])) {
         $variant->setName($array['name']);
     }
     if (isset($array['filename'])) {
         $variant->setFilename($array['filename']);
     }
     if (isset($array['options'])) {
         $variant->setOptions($array['options']);
     }
     if (isset($array['mode'])) {
         $variant->setMode($array['mode']);
     }
     if (isset($array['status'])) {
         $variant->setStatus($array['status']);
     }
     if (isset($array['error'])) {
         $variant->setError($array['error']);
     }
     if (isset($array['meta']) && is_array($array['meta']) && !empty($array['meta'])) {
         $variant->setMeta($array['meta']);
     }
     return $variant;
 }
예제 #3
0
 /**
  * {@inheritDoc}
  */
 public function buildVariantTree()
 {
     if ($this->lastTree) {
         return $this->lastTree;
     }
     $tree = new VariantTree();
     foreach ($this->variants as $name => $v) {
         //sets default values if any
         $mode = VariantInterface::MODE_INSTANT;
         if (isset($v['mode'])) {
             $mode = $v['mode'];
         }
         $process = array();
         if (isset($v['process'])) {
             $process = $v['process'];
         }
         $parent = NULL;
         if (isset($v['parent'])) {
             $parent = $v['parent'];
         }
         //creates the variant instance
         $variant = new Variant();
         $variant->setName($name);
         $variant->setMode($mode);
         $variant->setOptions($process);
         $tree->add($variant, $parent);
     }
     $this->lastTree = $tree;
     return $tree;
 }