本文整理汇总了PHP中Zend\Stdlib\Hydrator\ClassMethods::addFilter方法的典型用法代码示例。如果您正苦于以下问题:PHP ClassMethods::addFilter方法的具体用法?PHP ClassMethods::addFilter怎么用?PHP ClassMethods::addFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Stdlib\Hydrator\ClassMethods
的用法示例。
在下文中一共展示了ClassMethods::addFilter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createService
/**
* Create service
*
* @param ServiceLocatorInterface $serviceLocator
* @return mixed
*/
public function createService(ServiceLocatorInterface $serviceLocator)
{
$classmethod = new ClassMethods(false);
$classmethod->addFilter("arraycoppy", new MethodMatchFilter("getArrayCopy"), FilterComposite::CONDITION_AND);
$classmethod->addFilter("inputFilter", new MethodMatchFilter("getInputFilter"), FilterComposite::CONDITION_AND);
return new UserService($serviceLocator->get('Zend\\Db\\Adapter\\Adapter'), $classmethod);
}
示例2: createService
public function createService(ServiceLocatorInterface $serviceLocator)
{
$classmethod = new ClassMethods(false);
$classmethod->addFilter("arraycoppy", new MethodMatchFilter("getArrayCopy"), FilterComposite::CONDITION_AND);
$classmethod->addFilter("user", new MethodMatchFilter("getUser"), FilterComposite::CONDITION_AND);
$prototypeArr = new \ArrayObject();
$prototypeArr->append(new User());
return new ZendDbSqlMapper($serviceLocator->get('Zend\\Db\\Adapter\\Adapter'), $classmethod, new Page(), $prototypeArr);
}
示例3: getHydrator
public function getHydrator()
{
if (!$this->hydrator) {
$hydrator = new ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
$hydrator->addFilter('getQuery', new Filter\MethodMatchFilter('getQuery'), Filter\FilterComposite::CONDITION_AND);
$hydrator->addFilter('getHydrator', new Filter\MethodMatchFilter('getHydrator'), Filter\FilterComposite::CONDITION_AND);
$this->hydrator = $hydrator;
}
return $this->hydrator;
}
示例4: getHydrator
public function getHydrator()
{
if (!$this->hydrator) {
$hydrator = new ClassMethods();
$hydrator->addFilter('getHydrator', new Filter\MethodMatchFilter('getHydrator'), Filter\FilterComposite::CONDITION_AND);
foreach (get_class_methods(get_parent_class()) as $parentMethod) {
if (!preg_match('/^get/', $parentMethod) && !preg_match('/^has/', $parentMethod)) {
continue;
}
$hydrator->addFilter($parentMethod, new Filter\MethodMatchFilter($parentMethod), Filter\FilterComposite::CONDITION_AND);
}
$this->hydrator = $hydrator;
}
return $this->hydrator;
}
示例5: __construct
public function __construct()
{
$hydrator = new ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
foreach (array('getHydrator') as $method) {
$hydrator->addFilter($method, new Filter\MethodMatchFilter($method), Filter\FilterComposite::CONDITION_AND);
}
$this->setHydrator($hydrator);
}
示例6: __construct
public function __construct(ResourceNS\Status $status)
{
$this->setStatus($status);
$hydrator = new ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
foreach (array('getHydrator', 'isSuccessful') as $method) {
$hydrator->addFilter($method, new Filter\MethodMatchFilter($method), Filter\FilterComposite::CONDITION_AND);
}
$this->setHydrator($hydrator);
}
示例7: __construct
public function __construct(Credentials\CredentialsInterface $credentials)
{
$this->setCredentials($credentials);
$hydrator = new ClassMethods();
$hydrator->setUnderscoreSeparatedKeys(false);
foreach (array('getRequestPath', 'getRequestParams', 'getResponseType', 'getBasePath', 'getPath', 'getFormat', 'getCredentials', 'getHydrator') as $method) {
$hydrator->addFilter($method, new Filter\MethodMatchFilter($method), Filter\FilterComposite::CONDITION_AND);
}
$this->setHydrator($hydrator);
$this->setFormat(ResponseInterface::FORMAT_XML);
}
示例8: testHydratorClassMethodsWithCustomFilter
public function testHydratorClassMethodsWithCustomFilter()
{
$hydrator = new ClassMethods(false);
$datas = $hydrator->extract($this->classMethodsCamelCase);
$hydrator->addFilter("exclude", function ($property) {
list($class, $method) = explode('::', $property);
if ($method == 'getHasFoo') {
return false;
}
return true;
}, FilterComposite::CONDITION_AND);
$datas = $hydrator->extract($this->classMethodsCamelCase);
$this->assertFalse(isset($datas['hasFoo']));
}