com web/php: Undoing some of my over-architecting from a couple years back. Also showing more items on the homepage.:
Gateway/NewsFileSystemGateway.php Gateway/NewsGateway.php View/HomepageNewsView.php index-beta.php
| From: | Levi Morrison | Date: | Wed, 10 Jul 2013 21:08:25 +0000 |
| Subject: | com web/php: Undoing some of my over-architecting from a couple years back. Also showing more items on the homepage.: Gateway/NewsFileSystemGateway.php Gateway/NewsGateway.php View/HomepageNewsView.php index-beta.php |
||
| Groups: | php.webmaster | ||
| Request: | Send a blank email to php-webmaster+get-16292@lists.php.net to get a copy of this message | ||
Commit: 9629983aa3f8feb5ce98120a8fbdf740efa6478d
Author: Levi Morrison <levim@php.net> Wed, 10 Jul 2013 15:08:25 -0600
Parents: 2c299d96da945b3a6c498b74638b69fabf78c021
Branches: responsive
Link: http://git.php.net/?p=web/php.git;a=commitdiff;h=9629983aa3f8feb5ce98120a8fbdf740efa6478d
Log:
Undoing some of my over-architecting from a couple years back. Also showing more items on the
homepage.
Changed paths:
M Gateway/NewsFileSystemGateway.php
M Gateway/NewsGateway.php
M View/HomepageNewsView.php
M index-beta.php
Diff:
diff --git a/Gateway/NewsFileSystemGateway.php b/Gateway/NewsFileSystemGateway.php
index 849ac7f..6bc6bb2 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 991cac4..9af903a 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 0f1d564..0d982ca 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 f865675..74bbc01 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();