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

[WIP] Feature/doctrine #497

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
86 changes: 43 additions & 43 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,47 +1,47 @@
{
"name": "zendframework/modules.zendframework.com",
"description": "ZF2 Modules Site",
"license": "BSD-3-Clause",
"homepage": "https://zfmodules.com",
"require": {
"php": "~5.5",
"ext-intl": "*",
"doctrine/doctrine-module": "^0.9.0",
"doctrine/doctrine-orm-module": "^0.9.1",
"doctrine/migrations": "^1.1",
"evandotpro/edp-github": "0.2.*",
"ezyang/htmlpurifier": "4.6.*",
"monolog/monolog": "~1.12",
"phing/phing": "~2.10",
"socalnick/scn-social-auth": "1.14.1",
"zendframework/zendframework": "~2.3.0",
"zf-commons/zfc-user": "1.0.*",
"zfcampus/zf-development-mode": "~2.0"
"name": "zendframework/modules.zendframework.com",
"description": "ZF2 Modules Site",
"license": "BSD-3-Clause",
"homepage": "https://zfmodules.com",
"require": {
"php": "~5.5",
"ext-intl": "*",
"doctrine/doctrine-module": "^0.9.0",
"doctrine/doctrine-orm-module": "^0.9.1",
"doctrine/migrations": "^1.1",
"evandotpro/edp-github": "0.2.*",
"ezyang/htmlpurifier": "4.6.*",
"monolog/monolog": "~1.12",
"phing/phing": "~2.10",
"socalnick/scn-social-auth": "1.14.1",
"zendframework/zendframework": "~2.3.0",
"zf-commons/zfc-user": "1.0.*",
"zfcampus/zf-development-mode": "~2.0"
},
"require-dev": {
"bjyoungblood/BjyProfiler": "1.1.0",
"fabpot/php-cs-fixer": "~1.4",
"fzaninotto/faker": "^1.4.0",
"phpunit/phpunit": "^4.8",
"zendframework/zend-developer-tools": "dev-master",
"zendframework/zftool": "dev-master"
},
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/Application",
"User\\": "module/User/src/User",
"ZfModule\\": "module/ZfModule/src/ZfModule"
},
"require-dev": {
"bjyoungblood/BjyProfiler": "1.1.0",
"fabpot/php-cs-fixer": "~1.4",
"fzaninotto/faker": "^1.4.0",
"phpunit/phpunit": "^4.8",
"zendframework/zend-developer-tools": "dev-master",
"zendframework/zftool": "dev-master"
},
"autoload": {
"psr-4": {
"Application\\": "module/Application/src/Application",
"User\\": "module/User/src/User",
"ZfModule\\": "module/ZfModule/src/ZfModule"
},
"classmap": [
"vendor/hybridauth/hybridauth/hybridauth/Hybrid",
"vendor/hybridauth/hybridauth/additional-providers/hybridauth-github/Providers"
]
},
"autoload-dev": {
"psr-4": {
"ApplicationTest\\": "module/Application/test/ApplicationTest",
"UserTest\\": "module/User/test/UserTest",
"ZfModuleTest\\": "module/ZfModule/test/ZfModuleTest"
}
"classmap": [
"vendor/hybridauth/hybridauth/hybridauth/Hybrid",
"vendor/hybridauth/hybridauth/additional-providers/hybridauth-github/Providers"
]
},
"autoload-dev": {
"psr-4": {
"ApplicationTest\\": "module/Application/test/ApplicationTest",
"UserTest\\": "module/User/test/UserTest",
"ZfModuleTest\\": "module/ZfModule/test/ZfModuleTest"
}
}
}
16 changes: 16 additions & 0 deletions module/Application/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace Application;

use Application\Controller;
use Application\Service;
use Application\View;
Expand Down Expand Up @@ -103,4 +105,18 @@
'sanitizeHtml' => View\Helper\SanitizeHtmlFactory::class,
],
],
'doctrine' => [
'driver' => [
'application_entities' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity'],
],
'orm_default' => [
'drivers' => [
'Application\Entity' => 'application_entities'
]
]
],
],
];
20 changes: 11 additions & 9 deletions module/Application/src/Application/Controller/IndexController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,25 +4,27 @@

use Zend\Feed\Writer\Feed;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\Paginator;
use Zend\View\Model\FeedModel;
use Zend\View\Model\ViewModel;
use ZfModule\Mapper;
use ZfModule\Mapper\ModuleToFeed;
use ZfModule\Service;

class IndexController extends AbstractActionController
{
const MODULES_PER_PAGE = 15;

/**
* @var Mapper\Module
* @var Service\Module
*/
private $moduleMapper;
private $moduleService;

/**
* @param Mapper\Module $moduleMapper
* @param Service\Module $moduleService
*/
public function __construct(Mapper\Module $moduleMapper)
public function __construct(Service\Module $moduleService)
{
$this->moduleMapper = $moduleMapper;
$this->moduleService = $moduleService;
}

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

$repositories = $this->moduleMapper->pagination($page, self::MODULES_PER_PAGE, $query, 'created_at', 'DESC');
$repositories = $this->moduleService->findModules($query, ['m.created_at DESC'], $page, self::MODULES_PER_PAGE);

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

// Get the recent modules
$page = 1;
$modules = $this->moduleMapper->pagination($page, self::MODULES_PER_PAGE, null, 'created_at', 'DESC');
$modules = $this->moduleService->findModules(null, ['m.created_at DESC'], $page, self::MODULES_PER_PAGE);

// Load them into the feed
$mapper = new Mapper\ModuleToFeed($feed, $url);
$mapper = new ModuleToFeed($feed, $url);
$mapper->addModules($modules);

// Render the feed
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Zend\Mvc\Controller\ControllerManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZfModule\Mapper;
use ZfModule\Service;

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

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

return new IndexController($moduleMapper);
return new IndexController($moduleService);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,28 @@

use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use ZfModule\Mapper;
use ZfModule\Service;

class SearchController extends AbstractActionController
{
/**
* @var Mapper\Module
* @var Service\Module
*/
private $moduleMapper;
private $moduleService;

/**
* @param Mapper\Module $moduleMapper
* @param Service\Module $moduleService
*/
public function __construct(Mapper\Module $moduleMapper)
public function __construct(Service\Module $moduleService)
{
$this->moduleMapper = $moduleMapper;
$this->moduleService = $moduleService;
}

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

$results = $this->moduleMapper->findByLike($query);
$results = $this->moduleService->findModules($query, ['m.name']);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@localheinz not sure about this but is it legal to place this param with his specific prefix m.name in the controller?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ins0

It's probably better not to expose internals to much - so how about (if need be) exposing a method which fill find modules by name, specifically (if that's what it does)?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that's what i thought too, i will change this, ty


$viewModel = new ViewModel([
'results' => $results,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use Zend\Mvc\Controller\ControllerManager;
use Zend\ServiceManager\FactoryInterface;
use Zend\ServiceManager\ServiceLocatorInterface;
use ZfModule\Mapper;
use ZfModule\Service;

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

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

return new SearchController($moduleMapper);
return new SearchController($moduleService);
}
}
4 changes: 2 additions & 2 deletions module/Application/view/application/index/index.phtml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
<strong><?php echo $this->escapeHtml($module->getIdentifier()); ?></strong>
</a>
</p>
<p><span class="zf-green">Created:</span> <?php echo $this->dateFormat($module->getCreatedAtDateTime(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); ?></p>
<p><span class="zf-green">Created:</span> <?php echo $this->dateFormat($module->getCreatedAt(), IntlDateFormatter::SHORT, IntlDateFormatter::SHORT); ?></p>
</div>
<div class="col-xs-4">
<a target="_blank" href="<?php echo $this->escapeHtmlAttr($module->getUrl()) ?>">Show module on GitHub</a>
Expand All @@ -55,6 +55,6 @@
</div>
</div>
</div>
<?php echo $this->newUsers(); ?>
<?php #echo $this->newUsers(); ?>
</div>
</div>
16 changes: 16 additions & 0 deletions module/User/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace User;

use User\Controller;
use User\GitHub;
use User\Mapper;
Expand Down Expand Up @@ -37,4 +39,18 @@
GitHub\LoginListener::class => GitHub\LoginListener::class,
],
],
'doctrine' => [
'driver' => [
'user_entities' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity'],
],
'orm_default' => [
'drivers' => [
'User\Entity' => 'user_entities'
]
]
],
],
];
16 changes: 16 additions & 0 deletions module/ZfModule/config/module.config.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

namespace ZfModule;

use EdpGithub\Client;
use ZfModule\Controller;
use ZfModule\Delegators\EdpGithubClientAuthenticator;
Expand Down Expand Up @@ -115,4 +117,18 @@
],
],
],
'doctrine' => [
'driver' => [
'zfmodule_entities' => [
'class' => 'Doctrine\ORM\Mapping\Driver\AnnotationDriver',
'cache' => 'array',
'paths' => [__DIR__ . '/../src/' . __NAMESPACE__ . '/Entity'],
],
'orm_default' => [
'drivers' => [
'ZfModule\Entity' => 'zfmodule_entities'
]
]
],
],
];
Loading