From 9629983aa3f8feb5ce98120a8fbdf740efa6478d Mon Sep 17 00:00:00 2001 From: Levi Morrison Date: Wed, 10 Jul 2013 15:08:25 -0600 Subject: [PATCH] Undoing some of my over-architecting from a couple years back. Also showing more items on the homepage. --- Gateway/NewsFileSystemGateway.php | 12 ++++++------ Gateway/NewsGateway.php | 8 ++++---- View/HomepageNewsView.php | 6 +++--- index-beta.php | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Gateway/NewsFileSystemGateway.php b/Gateway/NewsFileSystemGateway.php index 849ac7f96..6bc6bb282 100644 --- a/Gateway/NewsFileSystemGateway.php +++ b/Gateway/NewsFileSystemGateway.php @@ -37,18 +37,18 @@ class NewsFileSystemGateway implements NewsGateway { /** * @param int $max [optional] - * @return Traversable + * @return array */ public function getLatestArticles($max = 5) { - return new ArrayIterator(array_slice($this->articles, 0, $max)); + return array_slice($this->articles, 0, $max); } /** - * @param Traversable $categories + * @param array $categories * @param int $limit - * @return Traversable + * @return array */ - public function getArticlesForCategories(Traversable $categories, $limit = 5) { + public function getArticlesForCategories(array $categories, $limit = 5) { $result = array(); foreach ($this->articles as $item) { @@ -65,7 +65,7 @@ class NewsFileSystemGateway implements NewsGateway { } - return new ArrayIterator(array_slice($result, 0 , $limit)); + return array_slice($result, 0 , $limit); } diff --git a/Gateway/NewsGateway.php b/Gateway/NewsGateway.php index 991cac430..9af903aac 100644 --- a/Gateway/NewsGateway.php +++ b/Gateway/NewsGateway.php @@ -5,16 +5,16 @@ interface NewsGateway { /** * @abstract * @param int $max [optional] - * @return Traversable + * @return array */ function getLatestArticles($max = 5); /** * @abstract - * @param Traversable $categories + * @param array $categories * @param int $limit [optional] - * @return Traversable + * @return array */ - function getArticlesForCategories(Traversable $categories, $limit = 5); + function getArticlesForCategories(array $categories, $limit = 5); } diff --git a/View/HomepageNewsView.php b/View/HomepageNewsView.php index 0f1d56417..0d982ca6b 100644 --- a/View/HomepageNewsView.php +++ b/View/HomepageNewsView.php @@ -3,14 +3,14 @@ class HomepageNewsView { /** - * @var Traversable + * @var array */ protected $articles; /** - * @param Traversable $articles + * @param array $articles */ - public function __construct(Traversable $articles) { + public function __construct(array $articles) { $this->articles = $articles; } diff --git a/index-beta.php b/index-beta.php index f86567574..74bbc0170 100644 --- a/index-beta.php +++ b/index-beta.php @@ -79,9 +79,9 @@ if (is_array($CONF_TEASER) && $CONF_TEASER) { require_once './Gateway/NewsFileSystemGateway.php'; $NewsGateway = new NewsFileSystemGateway(); -$RecentNews = $NewsGateway->getArticlesForCategories(new ArrayIterator(array( +$RecentNews = $NewsGateway->getArticlesForCategories(array( "frontpage" -)), 2); +), 4); ob_start();