Skip to content

Commit

Permalink
Re-enabled input filtering by integrateing dfw-filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Wolf committed Jul 7, 2015
1 parent 2ab4447 commit 83e891c
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 35 deletions.
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,15 @@
"phpmd/phpmd": "~2.2",
"satooshi/php-coveralls": "dev-master",
"detailnet/dfw-commanding": "~0.2.3",
"detailnet/dfw-filtering": "~0.1.0",
"zendframework/zend-paginator": "2.*",
"doctrine/orm": "~2.4",
"doctrine/mongodb-odm": "1.0.*@dev",
"ramsey/uuid": "~2.8.1"
},
"suggest": {
"detailnet/dfw-commanding": "For usage of the Doctrine ORM/ODM based repositories",
"detailnet/dfw-filtering": "For usage of the Doctrine ORM/ODM based repositories",
"zendframework/zend-paginator": "For usage of the Doctrine ORM/ODM based repositories",
"doctrine/doctrine-orm-module": "For usage of the Doctrine ORM based repository",
"doctrine/doctrine-mongo-odm-module": "For usage of the Doctrine ODM based repository",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,9 +283,6 @@ protected function remove($entity)
// }
//
// $queryBuilder->where($queryBuilder->expr()->eq('id', $entity->getId()));
//
// die($queryBuilder->getQuery()->getDQL());
// // DELETE Application\Asset\WebModule\Entity\Asset asset WHERE id = 96
}

/**
Expand Down
49 changes: 25 additions & 24 deletions src/Detail/Persistence/Factory/Doctrine/BaseRepositoryFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

namespace Detail\Persistence\Factory\Doctrine;

//use Zend\InputFilter\InputFilterPluginManager;
use Zend\InputFilter\InputFilterPluginManager;
use Zend\ServiceManager\ServiceLocatorInterface;
use Zend\ServiceManager\FactoryInterface;

//use Application\Core\Domain\InputFilter;
use Detail\Filtering\InputFilter;

use Detail\Persistence\Repository\RepositoryInterface;
use Detail\Persistence\Exception;

Expand All @@ -20,21 +21,21 @@ abstract class BaseRepositoryFactory implements
public function createService(ServiceLocatorInterface $serviceLocator)
{
$repository = $this->createRepository($serviceLocator);
// $repositoryFilters = $this->getRepositoryFilters();
//
// if ($repository instanceof InputFilter\FilterAwareInterface
// && count($repositoryFilters)
// ) {
// /** @var InputFilterPluginManager $inputFilters */
// $inputFilters = $serviceLocator->get('InputFilterManager');
// $filters = array();
//
// foreach ($repositoryFilters as $filterType => $filter) {
// $filters[$filterType] = $inputFilters->get($filter);
// }
//
// $repository->setInputFilters($filters);
// }
$repositoryFilters = $this->getRepositoryFilters();

if ($repository instanceof InputFilter\FilterAwareInterface
&& count($repositoryFilters)
) {
/** @var InputFilterPluginManager $inputFilters */
$inputFilters = $serviceLocator->get('InputFilterManager');
$filters = array();

foreach ($repositoryFilters as $filterType => $filter) {
$filters[$filterType] = $inputFilters->get($filter);
}

$repository->setInputFilters($filters);
}

return $repository;
}
Expand All @@ -45,13 +46,13 @@ public function createService(ServiceLocatorInterface $serviceLocator)
*/
abstract public function createRepository(ServiceLocatorInterface $serviceLocator);

// /**
// * @return array
// */
// protected function getRepositoryFilters()
// {
// return array();
// }
/**
* @return array
*/
protected function getRepositoryFilters()
{
return array();
}

/**
* Get fully qualified class name of the repository.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Zend\ServiceManager\ServiceLocatorInterface;

//use Application\Core\Domain\InputFilter;
use Detail\Persistence\Repository\DocumentRepositoryInterface;
use Detail\Persistence\Exception;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Zend\ServiceManager\ServiceLocatorInterface;

//use Application\Core\Domain\InputFilter;
use Detail\Persistence\Repository\EntityRepositoryInterface;
use Detail\Persistence\Exception;

Expand Down
13 changes: 7 additions & 6 deletions src/Detail/Persistence/Repository/BaseRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,24 +4,25 @@

use Detail\Commanding\Command\Listing\Sort;

//use Application\Core\Domain\InputFilter;
use Detail\Filtering\InputFilter;

use Detail\Persistence\Exception;

abstract class BaseRepository implements
// InputFilter\FilterAwareInterface,
InputFilter\FilterAwareInterface,
RepositoryInterface
{
// use InputFilter\FilterAwareTrait;
use InputFilter\FilterAwareTrait;

// const FILTER_CREATE = 'create';
// const FILTER_UPDATE = 'update';
const FILTER_CREATE = 'create';
const FILTER_UPDATE = 'update';

/**
* @param array $inputFilters
*/
public function __construct(array $inputFilters = array())
{
// $this->setInputFilters($inputFilters);
$this->setInputFilters($inputFilters);
}

/**
Expand Down

0 comments on commit 83e891c

Please sign in to comment.