Ejemplo n.º 1
0
 public function __construct(array $elements = [])
 {
     $list = [];
     foreach ($elements as $data) {
         $list[] = $this->factoryElement($data);
     }
     parent::__construct($list);
 }
Ejemplo n.º 2
0
 public function __construct(array $elements = array())
 {
     $list = [];
     foreach ($elements as $product) {
         $list[] = new Product\Product($product);
     }
     parent::__construct($list);
 }
Ejemplo n.º 3
0
 public function add($element)
 {
     $skuId = $element->getId();
     if ($this->hasId($skuId)) {
         throw new UnexpectedValueException('Sku already exists!');
     }
     $this->index[] = $skuId;
     return parent::add($element);
 }
Ejemplo n.º 4
0
 /**
  * @param array $array Lista de resultados
  */
 public function load(array $array = null)
 {
     if ($array) {
         $list = [];
         if (array_key_exists('matches', $array)) {
             $matches = $array['matches'];
             unset($array['matches']);
         } elseif (array_key_exists('matches', $array[0])) {
             $matches = $array[0]['matches'];
             unset($array[0]['matches']);
             $array = $array[0];
         } else {
             parent::__construct($array);
             return $this;
         }
         foreach ($matches as $result) {
             $list[] = $this->factoryItem($result);
         }
         $array['itens'] = $list;
         parent::__construct($array);
         return $this;
     }
 }
Ejemplo n.º 5
0
 /**
  * @param \Gpupo\Search\Query\KeywordsInterface $keywords
  */
 public function __construct(KeywordsInterface $keywords = null)
 {
     $data = ['index' => null, 'filters' => null, 'keywords' => ['primary' => $keywords], 'fieldWeights' => [], 'limit' => 20, 'offset' => null, 'countableAttributes' => []];
     parent::__construct($data);
 }