This repository has been archived by the owner on Jan 8, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4764 from mouhamed/hydrator-filter-enabled-interface
Add interface `FilterEnabledInterface`
- Loading branch information
Showing
2 changed files
with
69 additions
and
1 deletion.
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,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); | ||
} |