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 __construct(array $elements = array()) { parent::__construct(); if (array_key_exists('id', $elements)) { $elements = [$elements]; } foreach ($elements as $data) { if (array_key_exists('ean', $data) && !is_array($data['ean'])) { $data['ean'] = [$data['ean']]; } $this->add(new Sku\Sku($data)); } }
/** * @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); }