1
0
mirror of https://github.com/php/web-php.git synced 2026-03-23 23:02:13 +01:00

Undoing some of my over-architecting from a couple years back. Also showing more items on the homepage.

This commit is contained in:
Levi Morrison
2013-07-10 15:08:25 -06:00
parent 2c299d96da
commit 9629983aa3
4 changed files with 15 additions and 15 deletions

View File

@@ -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);
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -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();