/** * Creates a new locale object and adds this object to the context. * * @param string $site Site code * @param string|null $langid Two letter ISO code for language * @param string|null $currencyid Three letter ISO code for currency */ protected function setLocale($site, $langid = null, $currencyid = null) { $siteManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($this->context)->getSubManager('site'); $search = $siteManager->createSearch(); $search->setConditions($search->compare('==', 'locale.site.code', $site)); $sites = $siteManager->searchItems($search); if (($siteItem = reset($sites)) === false) { throw new \Aimeos\Controller\ExtJS\Exception(sprintf('Site item for code "%1$s" not found', $site)); } $values = array('siteid' => $siteItem->getId()); $sitepath = array_keys($siteManager->getPath($siteItem->getId())); $sitetree = $this->getSiteIdsFromTree($siteManager->getTree($siteItem->getId())); $localeItem = new \Aimeos\MShop\Locale\Item\Standard($values, $siteItem, $sitepath, $sitetree); $localeItem->setLanguageId($langid); $localeItem->setCurrencyId($currencyid); $this->context->setLocale($localeItem); }
/** * Creates a new locale object and adds this object to the context. * * @param string $site Site code */ protected function setLocale($site) { $context = $this->getContext(); $locale = $context->getLocale(); $siteItem = null; $siteManager = \Aimeos\MShop\Locale\Manager\Factory::createManager($context)->getSubManager('site'); if ($site != '') { $search = $siteManager->createSearch(); $search->setConditions($search->compare('==', 'locale.site.code', $site)); $sites = $siteManager->searchItems($search); if (($siteItem = reset($sites)) === false) { throw new \Aimeos\Controller\ExtJS\Exception('Site item not found.'); } } $localeItem = new \Aimeos\MShop\Locale\Item\Standard(array(), $siteItem); $localeItem->setLanguageId($locale->getLanguageId()); $localeItem->setCurrencyId($locale->getCurrencyId()); if ($siteItem !== null) { $localeItem->setSiteId($siteItem->getId()); } $context->setLocale($localeItem); }