public function createConfigFromRepository(ContentRepository $repo) { $collection = $repo->getAll(); return $collection->reduce(function ($data, $page) { $data['pages'][$page->name] = ['description' => $page->description]; $page->textblocks->each(function ($textblock) use(&$data, $page) { $data['pages'][$page->name]['textblocks'][$textblock->name] = ['description' => $textblock->description, 'allows_html' => !!$textblock->allows_html]; }); $page->galleries->each(function ($gallery) use(&$data, $page) { $data['pages'][$page->name]['galleries'][$gallery->name] = ['description' => $gallery->description, 'is_single' => !!$gallery->is_single]; }); return $data; }, ['pages' => []]); }
/** *@test */ public function text_for_returns_a_default_value_if_supplied_and_if_no_content_value_exists() { $page = ContentRepository::makePage('test'); $page->addTextblock('intro', 'an introduction', false, ''); $this->assertEquals('this is the default', $page->textFor('intro', 'this is the default')); $this->assertEquals('also a default', $page->textFor('nonexisting block', 'also a default')); }
/** *@test */ public function a_textblocks_content_can_be_set() { $page = ContentRepository::makePage('home'); $textblock = $page->addTextblock('intro', 'the introduction', false); $textblock->setContent('Once upon a time, in a land far, far away...'); $this->seeInDatabase('ec_textblocks', ['id' => $textblock->id, 'name' => 'intro', 'content' => 'Once upon a time, in a land far, far away...']); }
/** *@test */ public function the_content_repo_can_return_a_collection_of_all_page_names_and_urls() { $repo = new ContentRepository(); $home = Page::create(['name' => 'home', 'description' => 'The homepage']); $about = Page::create(['name' => 'about', 'description' => 'The about page']); $expected = collect([['name' => 'home', 'url' => '/package-edible/pages/' . $home->id], ['name' => 'about', 'url' => '/package-edible/pages/' . $about->id]]); $this->assertEquals($expected, $repo->getPageListWithUrls()); }
public function about() { $aboutPage = $this->contentRepository->getPageByName('about us'); $members = TeamMember::ordered()->get(); return view('front.pages.about')->with(compact('aboutPage', 'members')); }
protected function getHomePage() { return $this->contentRepository->getPageByName('home page'); }