4
4
5
5
use Zend \Feed \Writer \Feed ;
6
6
use Zend \Mvc \Controller \AbstractActionController ;
7
+ use Zend \Paginator ;
7
8
use Zend \View \Model \FeedModel ;
8
9
use Zend \View \Model \ViewModel ;
9
- use ZfModule \Mapper ;
10
+ use ZfModule \Mapper \ModuleToFeed ;
11
+ use ZfModule \Service ;
10
12
11
13
class IndexController extends AbstractActionController
12
14
{
13
15
const MODULES_PER_PAGE = 15 ;
14
16
15
17
/**
16
- * @var Mapper \Module
18
+ * @var Service \Module
17
19
*/
18
- private $ moduleMapper ;
20
+ private $ moduleService ;
19
21
20
22
/**
21
- * @param Mapper \Module $moduleMapper
23
+ * @param Service \Module $moduleService
22
24
*/
23
- public function __construct (Mapper \Module $ moduleMapper )
25
+ public function __construct (Service \Module $ moduleService )
24
26
{
25
- $ this ->moduleMapper = $ moduleMapper ;
27
+ $ this ->moduleService = $ moduleService ;
26
28
}
27
29
28
30
/**
@@ -33,7 +35,7 @@ public function indexAction()
33
35
$ query = $ this ->params ()->fromQuery ('query ' , null );
34
36
$ page = (int ) $ this ->params ()->fromQuery ('page ' , 1 );
35
37
36
- $ repositories = $ this ->moduleMapper -> pagination ( $ page , self :: MODULES_PER_PAGE , $ query , ' created_at ' , ' DESC ' );
38
+ $ repositories = $ this ->moduleService -> findModules ( $ query , [ ' m. created_at DESC '], $ page , self :: MODULES_PER_PAGE );
37
39
38
40
return new ViewModel ([
39
41
'repositories ' => $ repositories ,
@@ -57,10 +59,10 @@ public function feedAction()
57
59
58
60
// Get the recent modules
59
61
$ page = 1 ;
60
- $ modules = $ this ->moduleMapper -> pagination ( $ page , self :: MODULES_PER_PAGE , null , ' created_at ' , ' DESC ' );
62
+ $ modules = $ this ->moduleService -> findModules ( null , [ ' m. created_at DESC '], $ page , self :: MODULES_PER_PAGE );
61
63
62
64
// Load them into the feed
63
- $ mapper = new Mapper \ ModuleToFeed ($ feed , $ url );
65
+ $ mapper = new ModuleToFeed ($ feed , $ url );
64
66
$ mapper ->addModules ($ modules );
65
67
66
68
// Render the feed
0 commit comments