Skip to content
This repository has been archived by the owner on Jan 8, 2020. It is now read-only.

Commit

Permalink
Merge pull request #4764 from mouhamed/hydrator-filter-enabled-interface
Browse files Browse the repository at this point in the history
Add interface `FilterEnabledInterface`
  • Loading branch information
weierophinney committed Jul 2, 2013
2 parents 5bb7624 + 50c20a1 commit b06c412
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 1 deletion.
2 changes: 1 addition & 1 deletion library/Zend/Stdlib/Hydrator/AbstractHydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Zend\Stdlib\Hydrator\StrategyEnabledInterface;
use Zend\Stdlib\Hydrator\Strategy\StrategyInterface;

abstract class AbstractHydrator implements HydratorInterface, StrategyEnabledInterface
abstract class AbstractHydrator implements HydratorInterface, StrategyEnabledInterface, FilterEnabledInterface
{
/**
* The list with strategies that this hydrator has.
Expand Down
68 changes: 68 additions & 0 deletions library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?php
/**
* Zend Framework (http://framework.zend.com/)
*
* @link http://github.com/zendframework/zf2 for the canonical source repository
* @copyright Copyright (c) 2005-2013 Zend Technologies USA Inc. (http://www.zend.com)
* @license http://framework.zend.com/license/new-bsd New BSD License
*/

namespace Zend\Stdlib\Hydrator;

use Zend\Stdlib\Hydrator\Filter\FilterInterface;
use Zend\Stdlib\Hydrator\Filter\FilterComposite;
use Zend\Stdlib\Hydrator\Filter\FilterProviderInterface;

interface FilterEnabledInterface extends FilterProviderInterface
{
/**
* Add a new filter to take care of what needs to be hydrated.
* To exclude e.g. the method getServiceLocator:
*
* <code>
* $composite->addFilter("servicelocator",
* function($property) {
* list($class, $method) = explode('::', $property);
* if ($method === 'getServiceLocator') {
* return false;
* }
* return true;
* }, FilterComposite::CONDITION_AND
* );
* </code>
*
* @param string $name Index in the composite
* @param callable|FilterInterface $filter
* @param int $condition
* @return FilterComposite
*/
public function addFilter($name, $filter, $condition = FilterComposite::CONDITION_OR);

/**
* Get the filter instance
*
* @return FilterComposite
*/
public function getFilter();

/**
* Check whether a specific filter exists at key $name or not
*
* @param string $name Index in the composite
* @return bool
*/
public function hasFilter($name);

/**
* Remove a filter from the composition.
* To not extract "has" methods, you simply need to unregister it
*
* <code>
* $filterComposite->removeFilter('has');
* </code>
*
* @param $name
* @return FilterComposite
*/
public function removeFilter($name);
}

0 comments on commit b06c412

Please sign in to comment.