db = $db; $this->config = $config; $this->criteriaValidationService = $criteriaValidationService; $this->collection = $collection; $this->collectionEntryClassName = $this->collection->getEntryClassName(); } /** * @param SiteRepository $siteRepository * @return mixed */ public function getFromRequest(SiteRepository $siteRepository) { $site = $siteRepository->getFromRequest(); $main_site_id = $site->getID(); $std_main_language_id = $site->std_main_language_id; if(isset($_GET['language'])) { $found = $this->findByAltPrimary(array('main_site_id' => $main_site_id,'code' => filter_var($_GET['language'],FILTER_SANITIZE_SPECIAL_CHARS))); } else { $found = $this->findByID($std_main_language_id); } return $found; } /** * @param ShopRepository $shopRepository * @param SiteRepository $siteRepository * @return \DynCom\mysyde\dcShop\classes\Shop|mixed */ public function getCurrShopFromRequest(ShopRepository $shopRepository, SiteRepository $siteRepository) { $currLanguage = $this->getFromRequest($siteRepository); $nullObj = $shopRepository->getNullObject(); if(!isset($currLanguage->company) || !isset($currLanguage->shop_code)) { return $nullObj; } $altPrimaryArr = [ 'company' => $currLanguage->company, 'code' => $currLanguage->shop_code ]; $found = $shopRepository->findByAltPrimary($altPrimaryArr); return $found; } /** * @param ShopLanguageRepository $shopLanguageRepository * @param SiteRepository $siteRepository * @return mixed */ public function getCurrShopLanguageFromRequest(ShopLanguageRepository $shopLanguageRepository, SiteRepository $siteRepository) { $currLanguage = $this->getFromRequest($siteRepository); $nullObj = $shopLanguageRepository->getNullObject(); if(!isset($currLanguage->company) || !isset($currLanguage->shop_code) || !isset($currLanguage->shop_language_code)) { return $nullObj; } return $shopLanguageRepository->findByAltPrimary(array('company' => $currLanguage->company,'shop_code' => $currLanguage->shop_code, 'code' => $currLanguage->shop_language_code)); } }