Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Add interface `FilterEnabledInterface` #4764

Merged
merged 1 commit into from

3 participants

@mouhamed

Add FilterEnabledInterface like StrategyEnabledInterface.
Continue discussion PR : #4752

@mouhamed mouhamed referenced this pull request
Closed

Hydrator refactoring #4752

@coveralls

Coverage Status

Coverage remained the same when pulling 50c20a1 on mouhamed:hydrator-filter-enabled-interface into ecbb3dd on zendframework:develop.

@weierophinney weierophinney commented on the diff
library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php
((15 lines not shown))
+
+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
@weierophinney Owner

move this argument to the next line, and put the first argument ("servicelocator") on a line of its own (i.e., all arguments on their own lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@weierophinney weierophinney referenced this pull request from a commit
@weierophinney weierophinney [#4764] CS fix
- one argument per line
8a11f89
@weierophinney weierophinney merged commit 50c20a1 into zendframework:develop
@weierophinney weierophinney was assigned
@mouhamed mouhamed deleted the mouhamed:hydrator-filter-enabled-interface branch
@mouhamed mouhamed restored the mouhamed:hydrator-filter-enabled-interface branch
@mouhamed mouhamed deleted the mouhamed:hydrator-filter-enabled-interface branch
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-stdlib
@weierophinney weierophinney Merge pull request zendframework/zf2#4764 from mouhamed/hydrator-filt…
…er-enabled-interface

Add interface `FilterEnabledInterface`
147d06d
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-stdlib
@weierophinney weierophinney [zendframework/zf2#4764] CS fix
- one argument per line
767ea04
@weierophinney weierophinney referenced this pull request from a commit in zendframework/zend-stdlib
@weierophinney weierophinney Merge branch 'feature/4764' into develop 4695150
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jul 1, 2013
  1. @mouhamed
This page is out of date. Refresh to see the latest.
View
2  library/Zend/Stdlib/Hydrator/AbstractHydrator.php
@@ -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.
View
68 library/Zend/Stdlib/Hydrator/FilterEnabledInterface.php
@@ -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
@weierophinney Owner

move this argument to the next line, and put the first argument ("servicelocator") on a line of its own (i.e., all arguments on their own lines).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
+ * );
+ * </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);
+}
Something went wrong with that request. Please try again.