public function __construct(array $elements = []) { $list = []; foreach ($elements as $data) { $list[] = $this->factoryElement($data); } parent::__construct($list); }
public function __construct(array $elements = array()) { $list = []; foreach ($elements as $product) { $list[] = new Product\Product($product); } parent::__construct($list); }
public function add($element) { $skuId = $element->getId(); if ($this->hasId($skuId)) { throw new UnexpectedValueException('Sku already exists!'); } $this->index[] = $skuId; return parent::add($element); }
/** * @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; } }
/** * @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); }