/**
  * @param mixed $specification_map Either 'SpecificationMap' instance or array suitable for creating one.
  */
 protected function setSpecificationMap($specification_map)
 {
     if ($specification_map instanceof SpecificationMap) {
         $this->specification_map = $specification_map;
     } elseif (is_array($specification_map)) {
         $this->specification_map = new SpecificationMap();
         foreach ($specification_map as $spec_key => $specification) {
             if ($specification instanceof SpecificationInterface) {
                 $this->specification_map->setItem($spec_key, $specification);
             } else {
                 $this->specification_map->setItem($spec_key, new Specification($specification));
             }
         }
     } else {
         throw new BadValueException(sprintf('Invalid argument given. Only the types "%s" and "array" are supported.', SpecificationMap::CLASS));
     }
 }
Example #2
0
 public function __construct(array $state = [])
 {
     $specification_map = new SpecificationMap();
     $specification_map->setItems(array('title' => new Specification(array('name' => 'title', 'options' => array('attribute' => 'headline'))), 'author' => new Specification(array('name' => 'author'))));
     return parent::__construct(array('name' => 'embed', 'options' => [], 'specification_map' => $specification_map));
 }