From 03c012ece56c1ac4a8ca692bfdfe0b13851df3f5 Mon Sep 17 00:00:00 2001 From: Patrick Date: Wed, 14 Jan 2015 21:04:27 +0100 Subject: [PATCH] renamed method to readBySlug. closes #14 --- 10-dynamic-pages.md | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/10-dynamic-pages.md b/10-dynamic-pages.md index 7da2eb5..6e5db14 100644 --- a/10-dynamic-pages.md +++ b/10-dynamic-pages.md @@ -48,7 +48,7 @@ namespace Example\Page; interface PageReader { - public function getContentBySlug($slug); + public function readBySlug($slug); } ``` @@ -73,7 +73,7 @@ class FilePageReader implements PageReader $this->pageFolder = $pageFolder; } - public function getContentBySlug($slug) + public function readBySlug($slug) { return 'I am a placeholder'; } @@ -106,7 +106,7 @@ Now go back to the `Page` controller and change the `show` method to the followi public function show($params) { $slug = $params['slug']; - $data['content'] = $this->pageReader->getContentBySlug($slug); + $data['content'] = $this->pageReader->readBySlug($slug); $html = $this->renderer->render('Page', $data); $this->response->setContent($html); } @@ -150,7 +150,7 @@ So far so good, now let's make our `FilePageReader` actually do some work. Again, let's check first that the proper type was passed into the method: ```php -public function getContentBySlug($slug) +public function readBySlug($slug) { if (!is_string($slug)) { throw new InvalidArgumentException('slug must be a string'); @@ -177,7 +177,7 @@ class InvalidPageException extends Exception } ``` -Then in the `FilePageReader` file add this code at the end of your `getContentBySlug` method: +Then in the `FilePageReader` file add this code at the end of your `readBySlug` method: ``` $path = "$this->pageFolder/$slug.md"; @@ -201,7 +201,7 @@ public function show($params) $slug = $params['slug']; try { - $data['content'] = $this->pageReader->getContentBySlug($slug); + $data['content'] = $this->pageReader->readBySlug($slug); } catch (InvalidPageException $e) { $this->response->setStatusCode(404); return $this->response->setContent('404 - Page not found');