/**
  * 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);
 }
 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);
 }
 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;
 }
 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;
 }
 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);
 }
 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);
 }
 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);
 }
Example #8
0
 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']));
 }