Skip to content
This repository was archived by the owner on May 1, 2019. It is now read-only.

Commit 16ddc84

Browse files
author
Marco Rieger
committed
Update Application Folder to fit with new Doctrine Entities
1 parent fd33952 commit 16ddc84

File tree

8 files changed

+42
-39
lines changed

8 files changed

+42
-39
lines changed

module/Application/src/Application/Controller/IndexController.php

+11-9
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,27 @@
44

55
use Zend\Feed\Writer\Feed;
66
use Zend\Mvc\Controller\AbstractActionController;
7+
use Zend\Paginator;
78
use Zend\View\Model\FeedModel;
89
use Zend\View\Model\ViewModel;
9-
use ZfModule\Mapper;
10+
use ZfModule\Mapper\ModuleToFeed;
11+
use ZfModule\Service;
1012

1113
class IndexController extends AbstractActionController
1214
{
1315
const MODULES_PER_PAGE = 15;
1416

1517
/**
16-
* @var Mapper\Module
18+
* @var Service\Module
1719
*/
18-
private $moduleMapper;
20+
private $moduleService;
1921

2022
/**
21-
* @param Mapper\Module $moduleMapper
23+
* @param Service\Module $moduleService
2224
*/
23-
public function __construct(Mapper\Module $moduleMapper)
25+
public function __construct(Service\Module $moduleService)
2426
{
25-
$this->moduleMapper = $moduleMapper;
27+
$this->moduleService = $moduleService;
2628
}
2729

2830
/**
@@ -33,7 +35,7 @@ public function indexAction()
3335
$query = $this->params()->fromQuery('query', null);
3436
$page = (int) $this->params()->fromQuery('page', 1);
3537

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);
3739

3840
return new ViewModel([
3941
'repositories' => $repositories,
@@ -57,10 +59,10 @@ public function feedAction()
5759

5860
// Get the recent modules
5961
$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);
6163

6264
// Load them into the feed
63-
$mapper = new Mapper\ModuleToFeed($feed, $url);
65+
$mapper = new ModuleToFeed($feed, $url);
6466
$mapper->addModules($modules);
6567

6668
// Render the feed

module/Application/src/Application/Controller/IndexControllerFactory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Zend\Mvc\Controller\ControllerManager;
66
use Zend\ServiceManager\FactoryInterface;
77
use Zend\ServiceManager\ServiceLocatorInterface;
8-
use ZfModule\Mapper;
8+
use ZfModule\Service;
99

1010
class IndexControllerFactory implements FactoryInterface
1111
{
@@ -19,9 +19,9 @@ public function createService(ServiceLocatorInterface $controllerManager)
1919
/* @var ControllerManager $controllerManager */
2020
$serviceManager = $controllerManager->getServiceLocator();
2121

22-
/* @var Mapper\Module $moduleMapper */
23-
$moduleMapper = $serviceManager->get(Mapper\Module::class);
22+
/* @var Service\Module $moduleService */
23+
$moduleService = $serviceManager->get(Service\Module::class);
2424

25-
return new IndexController($moduleMapper);
25+
return new IndexController($moduleService);
2626
}
2727
}

module/Application/src/Application/Controller/SearchController.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,28 @@
44

55
use Zend\Mvc\Controller\AbstractActionController;
66
use Zend\View\Model\ViewModel;
7-
use ZfModule\Mapper;
7+
use ZfModule\Service;
88

99
class SearchController extends AbstractActionController
1010
{
1111
/**
12-
* @var Mapper\Module
12+
* @var Service\Module
1313
*/
14-
private $moduleMapper;
14+
private $moduleService;
1515

1616
/**
17-
* @param Mapper\Module $moduleMapper
17+
* @param Service\Module $moduleService
1818
*/
19-
public function __construct(Mapper\Module $moduleMapper)
19+
public function __construct(Service\Module $moduleService)
2020
{
21-
$this->moduleMapper = $moduleMapper;
21+
$this->moduleService = $moduleService;
2222
}
2323

2424
public function indexAction()
2525
{
2626
$query = $this->params()->fromQuery('query', null);
2727

28-
$results = $this->moduleMapper->findByLike($query);
28+
$results = $this->moduleService->findModules($query, ['m.name']);
2929

3030
$viewModel = new ViewModel([
3131
'results' => $results,

module/Application/src/Application/Controller/SearchControllerFactory.php

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Zend\Mvc\Controller\ControllerManager;
66
use Zend\ServiceManager\FactoryInterface;
77
use Zend\ServiceManager\ServiceLocatorInterface;
8-
use ZfModule\Mapper;
8+
use ZfModule\Service;
99

1010
class SearchControllerFactory implements FactoryInterface
1111
{
@@ -19,9 +19,9 @@ public function createService(ServiceLocatorInterface $controllerManager)
1919
/* @var ControllerManager $controllerManager */
2020
$serviceManager = $controllerManager->getServiceLocator();
2121

22-
/* @var Mapper\Module $moduleMapper */
23-
$moduleMapper = $serviceManager->get(Mapper\Module::class);
22+
/* @var Service\Module $moduleService */
23+
$moduleService = $serviceManager->get(Service\Module::class);
2424

25-
return new SearchController($moduleMapper);
25+
return new SearchController($moduleService);
2626
}
2727
}

module/Application/view/application/index/index.phtml

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
<strong><?php echo $this->escapeHtml($module->getIdentifier()); ?></strong>
3030
</a>
3131
</p>
32-
<p><span class="zf-green">Created:</span> <?php echo $this->dateFormat($module->getCreatedAtDateTime(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); ?></p>
32+
<p><span class="zf-green">Created:</span> <?php echo $this->dateFormat($module->getCreatedAt(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); ?></p>
3333
</div>
3434
<div class="col-xs-4">
3535
<a target="_blank" href="<?php echo $this->escapeHtmlAttr($module->getUrl()) ?>">Show module on GitHub</a>
@@ -55,6 +55,6 @@
5555
</div>
5656
</div>
5757
</div>
58-
<?php echo $this->newUsers(); ?>
58+
<?php #echo $this->newUsers(); ?>
5959
</div>
6060
</div>

module/ZfModule/src/ZfModule/Mapper/ModuleToFeed.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function addModule(ModuleEntity $module)
6565
$entry->setDescription($moduleDescription);
6666
$entry->setLink($this->urlPlugin->fromRoute('view-module', $urlParams, ['force_canonical' => true]));
6767
$entry->addAuthor(['name' => $module->getOwner()]);
68-
$entry->setDateCreated($module->getCreatedAtDateTime());
68+
$entry->setDateCreated($module->getCreatedAt());
6969

7070
$this->feed->addEntry($entry);
7171

module/ZfModule/src/ZfModule/View/Helper/TotalModules.php

+7-7
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,26 @@
33
namespace ZfModule\View\Helper;
44

55
use Zend\View\Helper\AbstractHelper;
6-
use ZfModule\Mapper;
6+
use ZfModule\Service;
77

88
class TotalModules extends AbstractHelper
99
{
1010
/**
11-
* @var Mapper\Module
11+
* @var Service\Module
1212
*/
13-
private $moduleMapper;
13+
private $moduleService;
1414

1515
/**
1616
* @var int
1717
*/
1818
private $total;
1919

2020
/**
21-
* @param Mapper\Module $moduleMapper
21+
* @param Service\Module $moduleService
2222
*/
23-
public function __construct(Mapper\Module $moduleMapper)
23+
public function __construct(Service\Module $moduleService)
2424
{
25-
$this->moduleMapper = $moduleMapper;
25+
$this->moduleService = $moduleService;
2626
}
2727

2828
/**
@@ -31,7 +31,7 @@ public function __construct(Mapper\Module $moduleMapper)
3131
public function __invoke()
3232
{
3333
if ($this->total === null) {
34-
$this->total = $this->moduleMapper->getTotal();
34+
$this->total = $this->moduleService->getTotalModuleCount();
3535
}
3636

3737
return $this->total;

module/ZfModule/src/ZfModule/View/Helper/TotalModulesFactory.php

+6-5
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22

33
namespace ZfModule\View\Helper;
44

5+
use Doctrine\ORM\EntityManager;
56
use Zend\ServiceManager\FactoryInterface;
67
use Zend\ServiceManager\ServiceLocatorInterface;
78
use Zend\View\HelperPluginManager;
8-
use ZfModule\Mapper;
9+
use ZfModule\Service;
910

1011
class TotalModulesFactory implements FactoryInterface
1112
{
@@ -17,11 +18,11 @@ class TotalModulesFactory implements FactoryInterface
1718
public function createService(ServiceLocatorInterface $helperPluginManager)
1819
{
1920
/* @var HelperPluginManager $helperPluginManager */
20-
$serviceManager = $helperPluginManager->getServiceLocator();
21+
$serviceLocator = $helperPluginManager->getServiceLocator();
2122

22-
/* @var Mapper\Module $moduleMapper */
23-
$moduleMapper = $serviceManager->get(Mapper\Module::class);
23+
/* @var Module $moduleService */
24+
$moduleService = $serviceLocator->get(Service\Module::class);
2425

25-
return new TotalModules($moduleMapper);
26+
return new TotalModules($moduleService);
2627
}
2728
}

0 commit comments

Comments
 (0)