コード例 #1
0
ファイル: ShopHydrator.php プロジェクト: GerDner/luck-docker
 /**
  * @param array $data
  * @return Shop
  */
 public function hydrate($data)
 {
     $shop = new Shop();
     $shop->setId((int) $data['__shop_id']);
     $shop->setIsDefault((bool) $data['__shop_default']);
     $shop->setName($data['__shop_name']);
     $shop->setTitle($data['__shop_title']);
     $shop->setFallbackId((int) $data['__shop_fallback_id']);
     $shop->setCurrency($this->currencyHydrator->hydrate($data));
     $shop->setCustomerGroup($this->customerGroupHydrator->hydrate($data));
     $shop->setCategory($this->categoryHydrator->hydrate($data));
     $shop->setLocale($this->localeHydrator->hydrate($data));
     $parent = $data;
     if ($data['parent']) {
         $parent = $data['parent'];
     }
     $shop->setTemplate($this->templateHydrator->hydrate($parent));
     $shop->setParentId((int) $parent['__shop_id']);
     $shop->setHost($parent['__shop_host']);
     $shop->setPath($parent['__shop_base_path']);
     $shop->setUrl($data['__shop_base_url'] ?: $parent['__shop_base_url']);
     $shop->setSecure((bool) $parent['__shop_secure']);
     $shop->setSecureHost($parent['__shop_secure_host']);
     $shop->setSecurePath($parent['__shop_secure_base_path']);
     $hosts = [];
     if ($parent['__shop_hosts']) {
         $hosts = explode('\\n', $parent['__shop_hosts']);
         $hosts = array_unique(array_values(array_filter($hosts)));
     }
     $shop->setHosts($hosts);
     return $shop;
 }