public function test_it_can_give_me_primary_language_id() { $Config = m::mock('Illuminate\\Config\\Repository'); $Config->shouldReceive('get')->times(1)->andReturn(45); $LanguageDetector = new LanguageDetector(new LocaleDetector($this->Framework), new \DvsLanguage(), $Config); assertEquals(45, $LanguageDetector->primaryLanguageId()); }
/** * @param \DvsMenu $Menu * @param \DvsMenuItem $MenuItem * @param LanguageDetector $LanguageDetector * @param Framework $Framework */ public function __construct(\DvsMenu $Menu, \DvsMenuItem $MenuItem, LanguageDetector $LanguageDetector, UserHelper $UserHelper, Framework $Framework) { $this->Menu = $Menu; $this->MenuItem = $MenuItem; $this->LanguageDetector = $LanguageDetector; $this->currentLanguage = $LanguageDetector->current(); $this->Input = $Framework->Input; $this->UserHelper = $UserHelper; }
/** * Wrap all fields around the page * * @param Page $page * @param $pageVersion * @return Page */ protected function wrapFieldsAroundPage($page, $pageVersion) { $language = $this->LanguageDetector->current(); $globalFields = $this->GlobalField->where('language_id', $language->id)->get(); $page = $this->wrapTheseFieldsAroundThisPage($globalFields, $page); $page = $this->wrapTheseFieldsAroundThisPage($pageVersion->fields, $page); $page = $this->wrapTheseCollectionsAroundThisPage($this->CollectionsRepository->findCollectionsForPageVersion($pageVersion), $page); return $page; }
/** * Wrap all fields around the page * * @param Page $page * @param $pageVersion * @return Page */ protected function wrapFieldsAroundPage($page, $pageVersion) { $language = $this->LanguageDetector->current(); // loading primary language if language cannot be detected $languageId = $language ? $language->id : $this->Config->get('devise.primary_language_id.primary_language_id'); $globalFields = $this->GlobalField->where('language_id', $languageId)->get(); $page = $this->wrapTheseFieldsAroundThisPage($globalFields, $page); $page = $this->wrapTheseFieldsAroundThisPage($pageVersion->fields, $page); $page = $this->wrapTheseCollectionsAroundThisPage($this->CollectionsRepository->findCollectionsForPageVersion($pageVersion), $page); return $page; }