Changeset 1323

Show
Ignore:
Timestamp:
02/03/08 21:29:43 (7 months ago)
Author:
mikey
Message:

BC-break: refactored net::stubbles::request::filters - more power by less code

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubAbstractFilterAnnotation.php

    r1307 r1323  
    3333     */ 
    3434    protected $rveFactoryClass; 
     35    /** 
     36     * the created rve factory 
     37     * 
     38     * @var  stubRequestValueErrorFactory 
     39     */ 
     40    protected $rveFactory      = null; 
    3541    /** 
    3642     * switch whether the value is required or not 
     
    125131    { 
    126132        $filter = $this->doGetFilter(); 
    127         $filter->setRequired($this->isRequired); 
    128         $filter->setDefaultValue($this->defaultValue); 
     133        if (true === $this->isRequired) { 
     134            $filter = new stubRequiredFilterDecorator($filter, $this->createRVEFactory()); 
     135        } 
     136         
     137        if (null !== $this->defaultValue) { 
     138            $filter = new stubDefaultValueFilterDecorator($filter, $this->defaultValue); 
     139        } 
     140         
    129141        return $filter; 
    130142    } 
     
    146158    protected function createRVEFactory() 
    147159    { 
     160        if (null !== $this->rveFactory) { 
     161            return $this->rveFactory; 
     162        } 
     163         
    148164        if (null != $this->rveFactoryClass) { 
    149165            $rveFactory = $this->rveFactoryClass->newInstance(); 
     
    151167                throw new stubRequestBrokerException('Created request value error factory is not an instance of stubRequestValueErrorFactory'); 
    152168            } 
     169             
     170            $this->rveFactory = $rveFactory; 
    153171        } else { 
    154172            stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorXJConfFactory'); 
    155             $rveFactory = new stubRequestValueErrorXJConfFactory(); 
     173            $this->rveFactory = new stubRequestValueErrorXJConfFactory(); 
    156174        } 
    157175         
    158176        if (count($this->mappings) === 0) { 
    159             return $rveFactory; 
     177            return $this->rveFactory; 
    160178        } 
    161179         
    162180        stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactoryMappingDecorator'); 
    163         $rveMappingDecorator = new stubRequestValueErrorFactoryMappingDecorator($rveFactory); 
     181        $this->rveFactory = new stubRequestValueErrorFactoryMappingDecorator($this->rveFactory); 
    164182        foreach ($this->mappings as $oldErrorId => $newErrorId) { 
    165             $rveMappingDecorator->addMapping($oldErrorId, $newErrorId); 
     183            $this->rveFactory->addMapping($oldErrorId, $newErrorId); 
    166184        } 
    167185         
    168         return $rveMappingDecorator
     186        return $this->rveFactory
    169187    } 
    170188 
  • trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubStringFilterAnnotation.php

    r1301 r1323  
    77 * @subpackage  ipo_request_broker_annotations 
    88 */ 
    9 stubClassLoader::load('net::stubbles::reflection::annotations::stubAnnotation', 
     9stubClassLoader::load('net::stubbles::ipo::request::broker::annotations::stubAbstractStringFilterAnnotation', 
     10                      'net::stubbles::ipo::request::filters::stubRegexCheckFilterDecorator', 
    1011                      'net::stubbles::ipo::request::filters::stubStringFilter', 
    11                       'net::stubbles::ipo::request::broker::annotations::stubAbstractFilterAnnotation', 
    12                       'net::stubbles::php::string::stubStringEncoder', 
    13                       'net::stubbles::util::validators::stubMaxLengthValidator', 
    14                       'net::stubbles::util::validators::stubMinLengthValidator', 
    1512                      'net::stubbles::util::validators::stubRegexValidator' 
    1613); 
     
    2118 * @subpackage  ipo_request_broker_annotations 
    2219 */ 
    23 class stubStringFilterAnnotation extends stubAbstractFilterAnnotation implements stubAnnotation 
     20class stubStringFilterAnnotation extends stubAbstractStringFilterAnnotation 
    2421{ 
    25     /** 
    26      * minimum length of the string 
    27      * 
    28      * @var  int 
    29      */ 
    30     protected $minLength; 
    31     /** 
    32      * maximum length of the string 
    33      * 
    34      * @var  int 
    35      */ 
    36     protected $maxLength; 
    3722    /** 
    3823     * regular expression to filter the string 
     
    4025     * @var  string 
    4126     */ 
    42     protected $regex        = null; 
    43     /** 
    44      * the encoder class to be used 
    45      * 
    46      * @var  stubReflectionClass 
    47      */ 
    48     protected $encoderClass = null; 
    49     /** 
    50      * the encoding mode to be applied 
    51      * 
    52      * @var  int 
    53      */ 
    54     protected $encoderMode  = stubStringEncoder::MODE_DECODE; 
    55  
    56     /** 
    57      * checks if the regex property is set and if the encoder mode is correct 
    58      * 
    59      * @throws  ReflectionException 
    60      */ 
    61     public function finish() 
    62     { 
    63         if (null == $this->regex) { 
    64             throw new ReflectionException('Can not use ' . $this->getClassName() . ' without setting the regular expression via regex property.'); 
    65         } 
    66          
    67         if (null !== $this->encoderClass && in_array($this->encoderMode, array(stubStringEncoder::MODE_DECODE, stubStringEncoder::MODE_ENCODE)) === false) { 
    68             throw new ReflectionException('Can not use ' . $this->getClassName() . ' with wrong encoder mode ' . $this->encoderMode); 
    69         } 
    70     } 
    71  
    72     /** 
    73      * sets the minimum length of the string 
    74      * 
    75      * @param  int  $minLength 
    76      */ 
    77     public function setMinLength($minLength) 
    78     { 
    79         $this->minLength = $minLength; 
    80     } 
    81  
    82     /** 
    83      * sets the maximum length of the string 
    84      * 
    85      * @param  int  $maxLength 
    86      */ 
    87     public function setMaxLength($maxLength) 
    88     { 
    89         $this->maxLength = $maxLength; 
    90     } 
     27    protected $regex = null; 
    9128 
    9229    /** 
     
    10138 
    10239    /** 
    103      * sets the encoder class to be used 
    104      * 
    105      * @param  stubReflectionClass  $encoderClass 
    106      */ 
    107     public function setEncoder(stubReflectionClass $encoderClass) 
    108     { 
    109         $this->encoderClass = $encoderClass; 
    110     } 
    111  
    112     /** 
    113      * sets the encoder mode to be used 
    114      * 
    115      * @param  int  $mode 
    116      */ 
    117     public function setEncoderMode($mode) 
    118     { 
    119         $this->encoderMode = $mode; 
    120     } 
    121  
    122     /** 
    12340     * returns the filter defined by the annotation 
    12441     * 
    125      * @return  stubStringFilter 
    126      * @throws  stubRequestBrokerException 
     42     * @return  stubFilter 
    12743     */ 
    128     protected function doGetFilter() 
     44    protected function doDoGetFilter() 
    12945    { 
    130         $stringFilter  = new stubStringFilter($this->createRVEFactory(), new stubRegexValidator($this->regex)); 
    131         if (null !== $this->minLength) { 
    132             $stringFilter->setMinLengthValidator(new stubMinLengthValidator($this->minLength)); 
    133         } 
    134          
    135         if (null !== $this->maxLength) { 
    136             $stringFilter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength)); 
    137         } 
    138          
    139         if (null !== $this->encoderClass) { 
    140             $stringFilter->setEncoder($this->encoderClass->newInstance(), $this->encoderMode); 
     46        $stringFilter  = new stubStringFilter(); 
     47        if (null !== $this->regex) { 
     48            $stringFilter = new stubRegexCheckFilterDecorator($stringFilter, $this->createRVEFactory(), new stubRegexValidator($this->regex)); 
    14149        } 
    14250         
  • trunk/src/main/php/net/stubbles/ipo/request/broker/annotations/stubTextFilterAnnotation.php

    r1301 r1323  
    11<?php 
    22/** 
    3  * Filter annotation for strings. 
     3 * Filter annotation for texts. 
    44 * 
    55 * @author      Frank Kleine <mikey@stubbles.net> 
     
    77 * @subpackage  ipo_request_broker_annotations 
    88 */ 
    9 stubClassLoader::load('net::stubbles::reflection::annotations::stubAnnotation', 
    10                       'net::stubbles::ipo::request::filters::stubTextFilter', 
    11                       'net::stubbles::ipo::request::broker::annotations::stubAbstractFilterAnnotation', 
    12                       'net::stubbles::php::string::stubStringEncoder', 
    13                       'net::stubbles::util::validators::stubMaxLengthValidator', 
    14                       'net::stubbles::util::validators::stubMinLengthValidator', 
    15                       'net::stubbles::util::validators::stubRegexValidator' 
     9stubClassLoader::load('net::stubbles::ipo::request::filters::stubTextFilter', 
     10                      'net::stubbles::ipo::request::broker::annotations::stubAbstractStringFilterAnnotation' 
    1611); 
    1712/** 
    18  * Filter annotation for strings. 
     13 * Filter annotation for texts. 
    1914 * 
    2015 * @package     stubbles 
    2116 * @subpackage  ipo_request_broker_annotations 
    2217 */ 
    23 class stubTextFilterAnnotation extends stubAbstractFilterAnnotation implements stubAnnotation 
     18class stubTextFilterAnnotation extends stubAbstractStringFilterAnnotation 
    2419{ 
    25     /** 
    26      * minimum length of the string 
    27      * 
    28      * @var  int 
    29      */ 
    30     protected $minLength; 
    31     /** 
    32      * maximum length of the string 
    33      * 
    34      * @var  int 
    35      */ 
    36     protected $maxLength; 
    3720    /** 
    3821     * list of allowed tags 
     
    4124     */ 
    4225    protected $allowedTags = array(); 
    43     /** 
    44      * the encoder class to be used 
    45      * 
    46      * @var  stubReflectionClass 
    47      */ 
    48     protected $encoderClass = null; 
    49     /** 
    50      * the encoding mode to be applied 
    51      * 
    52      * @var  int 
    53      */ 
    54     protected $encoderMode  = stubStringEncoder::MODE_DECODE; 
    55  
    56     /** 
    57      * checks if the encoder mode is correct 
    58      * 
    59      * @throws  ReflectionException 
    60      */ 
    61     public function finish() 
    62     { 
    63         if (null !== $this->encoderClass && in_array($this->encoderMode, array(stubStringEncoder::MODE_DECODE, stubStringEncoder::MODE_ENCODE)) === false) { 
    64             throw new ReflectionException('Can not use ' . $this->getClassName() . ' with wrong encoder mode ' . $this->encoderMode); 
    65         } 
    66     } 
    67  
    68     /** 
    69      * sets the minimum length of the string 
    70      * 
    71      * @param  int  $minLength 
    72      */ 
    73     public function setMinLength($minLength) 
    74     { 
    75         $this->minLength = $minLength; 
    76     } 
    77  
    78     /** 
    79      * sets the maximum length of the string 
    80      * 
    81      * @param  int  $maxLength 
    82      */ 
    83     public function setMaxLength($maxLength) 
    84     { 
    85         $this->maxLength = $maxLength; 
    86     } 
    8726 
    8827    /** 
     
    10039 
    10140    /** 
    102      * sets the encoder class to be used 
    103      * 
    104      * @param  stubReflectionClass  $encoderClass 
    105      */ 
    106     public function setEncoder(stubReflectionClass $encoderClass) 
    107     { 
    108         $this->encoderClass = $encoderClass; 
    109     } 
    110  
    111     /** 
    112      * sets the encoder mode to be used 
    113      * 
    114      * @param  int  $mode 
    115      */ 
    116     public function setEncoderMode($mode) 
    117     { 
    118         $this->encoderMode = $mode; 
    119     } 
    120  
    121     /** 
    12241     * returns the filter defined by the annotation 
    12342     * 
    124      * @return  stubTextFilter 
    125      * @throws  stubRequestBrokerException 
     43     * @return  stubFilter 
    12644     */ 
    127     protected function doGetFilter() 
     45    protected function doDoGetFilter() 
    12846    { 
    129         $textFilter  = new stubTextFilter($this->createRVEFactory()); 
    130         if (null !== $this->minLength) { 
    131             $textFilter->setMinLengthValidator(new stubMinLengthValidator($this->minLength)); 
    132         } 
    133          
    134         if (null !== $this->maxLength) { 
    135             $textFilter->setMaxLengthValidator(new stubMaxLengthValidator($this->maxLength)); 
    136         } 
    137          
    138         if (null !== $this->encoderClass) { 
    139             $textFilter->setEncoder($this->encoderClass->newInstance(), $this->encoderMode); 
    140         } 
    141          
     47        $textFilter = new stubTextFilter(); 
    14248        $textFilter->setAllowedTags($this->allowedTags); 
    14349        return $textFilter; 
  • trunk/src/main/php/net/stubbles/ipo/request/broker/stubRequestBroker.php

    r1232 r1323  
    4242            $refClass = new stubReflectionClass(get_class($object)); 
    4343        } else { 
    44             throw new stubIllegalArgumentException('Parameter object must be a classname or a concrete object instance.'); 
     44            throw new stubIllegalArgumentException('Parameter object must a concrete object instance.'); 
    4545        } 
    4646         
    4747        foreach ($refClass->getProperties() as $refProperty) { 
    48             if ($this->isAvailable($refProperty) === false) { 
    49                 continue; 
    50             } 
    51              
    52             $filterAnnotation = $refProperty->getAnnotation('Filter'); 
    53             $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 
    54             if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 
    55                 $refProperty->setValue($object, $value); 
     48            if ($this->isAvailable($refProperty) === true) { 
     49                $filterAnnotation = $refProperty->getAnnotation('Filter'); 
     50                $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 
     51                if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 
     52                    $refProperty->setValue($object, $value); 
     53                } 
    5654            } 
    5755        } 
    5856         
    5957        foreach ($refClass->getMethods() as $refMethod) { 
    60             if ($this->isAvailable($refMethod) === false) { 
    61                 continue; 
    62             } 
    63              
    64             $filterAnnotation = $refMethod->getAnnotation('Filter'); 
    65             $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 
    66             if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 
    67                 $refMethod->invoke($object, $value); 
     58            if ($this->isAvailable($refMethod) === true) { 
     59                $filterAnnotation = $refMethod->getAnnotation('Filter'); 
     60                $value = $request->getFilteredValue($filterAnnotation->getFilter(), $prefix . $filterAnnotation->getFieldName()); 
     61                if ($request->hasValueError($prefix . $filterAnnotation->getFieldName()) === false) { 
     62                    $refMethod->invoke($object, $value); 
     63                } 
    6864            } 
    6965        } 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubAbstractFilterDecorator.php

    r1301 r1323  
    55 * 
    66 * @author      Richard Sternagel <richard.sternagel@1und1.de> 
     7 * @author      Frank Kleine <mikey@stubbles.net> 
    78 * @package     stubbles 
    89 * @subpackage  ipo_request_filters 
     
    4445        return $this->decoratedFilter; 
    4546    } 
    46  
    47     /** 
    48      * switch whether a value is required or not 
    49      * 
    50      * @param  bool  $required 
    51      */ 
    52     public function setRequired($required) 
    53     { 
    54         $this->decoratedFilter->setRequired($required); 
    55     } 
    56  
    57     /** 
    58      * set a default value in case the value to filter is not set 
    59      * 
    60      * @param  mixed  $defaultValue 
    61      */ 
    62     public function setDefaultValue($defaultValue) 
    63     { 
    64         $this->decoratedFilter->setDefaultValue($defaultValue); 
    65     } 
    66  
    67     /** 
    68      * returns true if the filter has a default value in case the value to filter is not set 
    69      * 
    70      * @return  bool 
    71      */ 
    72     public function hasDefaultValue() 
    73     { 
    74         return null != $this->decoratedFilter->defaultValue; 
    75     } 
    76  
    77     /** 
    78      * returns a default value in case the value to filter is not set 
    79      * 
    80      * @return  mixed 
    81      */ 
    82     public function getDefaultValue() 
    83     { 
    84         return $this->decoratedFilter->defaultValue; 
    85     } 
    8647} 
    8748?> 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubFilter.php

    r1223 r1323  
    2020{ 
    2121    /** 
    22      * switch whether a value is required or not 
    23      * 
    24      * @param  bool  $required 
    25      */ 
    26     public function setRequired($required); 
    27      
    28     /** 
    2922     * execute the filter 
    3023     * 
     
    3427     */ 
    3528    public function execute($value); 
    36  
    37     /** 
    38      * set a default value in case the value to filter is not set 
    39      * 
    40      * @param  mixed  $defaultValue 
    41      */ 
    42     public function setDefaultValue($defaultValue); 
    43  
    44     /** 
    45      * returns true if the filter has a default value in case the value to filter is not set 
    46      * 
    47      * @return  bool 
    48      */ 
    49     public function hasDefaultValue(); 
    50  
    51     /** 
    52      * returns a default value in case the value to filter is not set 
    53      * 
    54      * @return  mixed 
    55      */ 
    56     public function getDefaultValue(); 
    5729} 
    5830?> 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubFloatFilter.php

    r1281 r1323  
    5050    function execute($value) 
    5151    { 
    52         if ((strlen($value) > 0 && true == $this->isRequired) || false == $this->isRequired || false === $value) { 
    53             settype($value, 'float'); 
    54         } 
    55          
     52        settype($value, 'float'); 
    5653        $value    = parent::doExecute($value); 
    5754        $decimals = stubRegistry::getConfig(self::DECIMALS_REGISTRY_KEY); 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubHTTPURLFilter.php

    r1223 r1323  
    77 * @subpackage  ipo_request_filters 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilter', 
     9stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 
    1010                      'net::stubbles::util::net::http::stubHTTPURL' 
    1111); 
     
    1616 * @subpackage  ipo_request_filters 
    1717 */ 
    18 class stubHTTPURLFilter extends stubAbstractFilter 
     18class stubHTTPURLFilter extends stubBaseObject implements stubFilter 
    1919{ 
     20    /** 
     21     * request value error factory 
     22     * 
     23     * @var  stubRequestValueErrorFactory 
     24     */ 
     25    protected $rveFactory; 
    2026    /** 
    2127     * switch whether DNS should be checked or not 
     
    2329     * @var  bool 
    2430     */ 
    25     protected $checkDNS     = false; 
     31    protected $checkDNS  = false; 
    2632 
    2733    /** 
     
    7177         
    7278        if (null === $http) { 
    73             if (true === $this->isRequired) { 
    74                 throw new stubFilterException($this->rveFactory->create('URL_INCORRECT')); 
    75             } 
    76              
    7779            return null; 
    7880        } 
    7981         
    80         if (true === $this->checkDNS && $http->checkDNS() == false) { 
     82        if (true === $this->checkDNS && $http->checkDNS() === false) { 
    8183            throw new stubFilterException($this->rveFactory->create('URL_NOT_AVAILABLE')); 
    8284        } 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubIntegerFilter.php

    r1301 r1323  
    4141    function execute($value) 
    4242    { 
    43         if ((strlen($value) > 0 && true == $this->isRequired) || false == $this->isRequired || false === $value) { 
    44             settype($value, 'integer'); 
    45         } 
    46  
     43        settype($value, 'integer'); 
    4744        return parent::doExecute($value); 
    4845    } 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubMailFilter.php

    r1307 r1323  
    77 * @subpackage  ipo_request_filters 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilter', 
     9stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 
    1010                      'net::stubbles::util::validators::stubValidator' 
    1111); 
     
    1717 * @uses        net::stubbles::util::validators 
    1818 */ 
    19 class stubMailFilter extends stubAbstractFilter 
     19class stubMailFilter extends stubBaseObject implements stubFilter 
    2020{ 
     21    /** 
     22     * request value error factory 
     23     * 
     24     * @var  stubRequestValueErrorFactory 
     25     */ 
     26    protected $rveFactory; 
    2127    /** 
    2228     * validator to use for checking the mail address 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubNumberFilter.php

    r1301 r1323  
    77 * @subpackage  ipo_request_filters 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilter', 
    10                       'net::stubbles::ipo::request::stubRequestValueErrorFactory', 
     9stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactory', 
     10                      'net::stubbles::ipo::request::filters::stubFilter', 
    1111                      'net::stubbles::util::validators::stubValidator' 
    1212); 
     
    1919 * @package     stubbles 
    2020 * @subpackage  ipo_request_filters 
    21  * @uses        net::stubbles::util::validators 
    2221 */ 
    23 class stubNumberFilter extends stubAbstractFilter 
     22class stubNumberFilter extends stubBaseObject implements stubFilter 
    2423{ 
     24    /** 
     25     * request value error factory 
     26     * 
     27     * @var  stubRequestValueErrorFactory 
     28     */ 
     29    protected $rveFactory; 
    2530    /** 
    2631     * validator for minimum values 
     
    9297    protected function doExecute($value) 
    9398    { 
    94         if ((null === $value || strlen($value) === 0) && true === $this->isRequired) { 
    95             // add error message if there is no input and input is needed 
    96             throw new stubFilterException($this->rveFactory->create('FIELD_EMPTY')); 
    97         } elseif (null !== $value && null !== $this->minValidator && $this->minValidator->validate($value) !== true) { 
     99        if (null !== $value && null !== $this->minValidator && $this->minValidator->validate($value) !== true) { 
    98100             // add error message if input is smaller than minimum value 
    99101            throw new stubFilterException($this->rveFactory->create('VALUE_TOO_SMALL')->setValues($this->minValidator->getCriteria())); 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubPassThruFilter.php

    r1223 r1323  
    22/** 
    33 * Filter that filters nothing. 
    4  * 
    5  * Use this filter only when you know what you are doing. 
    64 * 
    75 * @author      Frank Kleine <mikey@stubbles.net> 
     
    97 * @subpackage  ipo_request_filters 
    108 */ 
    11 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilter'); 
     9stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter'); 
    1210/** 
    1311 * Filter that filters nothing. 
     
    1816 * @subpackage  ipo_request_filters 
    1917 */ 
    20 class stubPassThruFilter extends stubAbstractFilter 
     18class stubPassThruFilter extends stubBaseObject implements stubFilter 
    2119{ 
    22     /** 
    23      * constructor 
    24      * 
    25      * @param  stubRequestValueErrorFactory  $rveFactory  factory to create stubRequestValueErrors 
    26      */ 
    27     public function __construct(stubRequestValueErrorFactory $rveFactory) 
    28     { 
    29         $this->rveFactory = $rveFactory; 
    30     } 
    31  
    3220    /** 
    3321     * execute the filter 
     
    3927    public function execute($value) 
    4028    { 
    41         if (null === $value && true == $this->isRequired) { 
    42             throw new stubFilterException($this->rveFactory->create('FIELD_EMPTY')); 
    43         } 
    44  
    4529        return $value; 
    4630    } 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubPasswordFilter.php

    r1307 r1323  
    77 * @subpackage  ipo_request_filters 
    88 */ 
    9 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilter', 
     9stubClassLoader::load('net::stubbles::ipo::request::filters::stubFilter', 
    1010                      'net::stubbles::php::string::stubStringEncoder', 
    1111                      'net::stubbles::util::validators::stubValidator' 
     
    2929 * @uses        net::stubbles::util::validators 
    3030 */ 
    31 class stubPasswordFilter extends stubAbstractFilter 
     31class stubPasswordFilter extends stubBaseObject implements stubFilter 
    3232{ 
     33    /** 
     34     * request value error factory 
     35     * 
     36     * @var  stubRequestValueErrorFactory 
     37     */ 
     38    protected $rveFactory; 
    3339    /** 
    3440     * validator to use for checking the minimum length of the password 
     
    147153        } 
    148154 
    149         if (false === $this->isRequired && strlen($value) === 0) { 
    150             return null; 
    151         } 
    152  
    153155        if ($this->minLength->validate($value) === false) { 
    154156            throw new stubFilterException($this->rveFactory->create('STRING_TOO_SHORT')->setValues($this->minLength->getCriteria())); 
     
    165167        } 
    166168 
    167         return $this->secure($value); 
     169        if (strlen($value) > 0) { 
     170            return $this->secure($value); 
     171        } 
     172         
     173        return null; 
    168174    } 
    169175 
  • trunk/src/main/php/net/stubbles/ipo/request/filters/stubRegexChangeFilterDecorator.php

    r1301 r1323  
    11<?php 
    22/** 
    3  * Decorator which adds regex filtering (input value may be changed due to regex) 
    4  * and can therefore be used in conjunction with other filters. 
     3 * Class for changing values with a regular expression. 
    54 * 
    65 * @author      Richard Sternagel <richard.sternagel@1und1.de> 
     6 * @author      Frank Kleine <mikey@stubbles.net> 
    77 * @package     stubbles 
    88 * @subpackage  ipo_request_filters 
    99 */ 
    10 stubClassLoader::load('net::stubbles::ipo::request::filters::stubAbstractFilterDecorator', 
    11                       'net::stubbles::lang::exceptions::stubIllegalArgumentException', 
    12                       'net::stubbles::lang::exceptions::stubIllegalStateException' 
     10stubClassLoader::load('net::stubbles::ipo::request::stubRequestValueErrorFactory', 
     11                      'net::stubbles::ipo::request::filters::stubStrategyFilterDecorator' 
    1312); 
    1413/** 
    15  * Decorator which adds regex filtering (input value may be changed due to regex) 
    16  * and can therefore be used in conjunction with other filters. 
     14 * Class for changing values with a regular expression. 
     15 * 
     16 * This filter does a check against a regular expression and returns the 
     17 * requested match. If no match is found the returned value will be null. 
    1718 * 
    1819 * @package     stubbles 
    1920 * @subpackage  ipo_request_filters 
    2021 */ 
    21 class stubRegexFilterDecorator extends stubAbstractFilterDecorator 
     22class stubRegexChangeFilterDecorator extends stubStrategyFilterDecorator 
    2223{ 
    23     /** 
    24      * indicates the decorator behavior: 
    25      *  
    26      * decorate the filter (apply regex) *before* the 
    27      * actual method call. 
    28      */ 
    29     const STRATEGY_BEFORE = -1; 
    30     /** 
    31      * indicates the decorator behavior: 
    32      *  
    33      * decorate the filter (apply regex) *after* the 
    34      * actual method call. 
    35      */ 
    36     const STRATEGY_AFTER  = 1; 
    37     /** 
    38      * Decorator Strategy: 
    39      *  
    40      * <ul> 
    41      *   <li>self::BEFORE_STRAGTEGY</li> 
    42      *   <li>self::AFTER_STRATEGY</li> 
    43      * </ul> 
    44      * 
    45      * @var  int 
    46      */ 
    47     protecte