forked from zendframework/zendframework
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add new interface FilterEnabledInterface
- Loading branch information
Showing
2 changed files
with
98 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
<?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; | ||
|
||
interface FilterEnabledInterface | ||
{ | ||
/** | ||
* 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); | ||
} |