Skip to content

Instantly share code, notes, and snippets.

@awartoft
Created July 15, 2012 15:33
Show Gist options
  • Save awartoft/3117472 to your computer and use it in GitHub Desktop.
Save awartoft/3117472 to your computer and use it in GitHub Desktop.
<?php
/**
* @author Antoine Hedgecock <[email protected]>
*/
/**
* @namespace
*/
namespace User\Form\Account;
use Zend\Form\Form,
Zend\InputFilter\InputFilter,
Zend\Stdlib\Hydrator\ClassMethods,
Zend\ServiceManager\ServiceManager,
Zend\ServiceManager\ServiceManagerAwareInterface;
class Register extends Form implements ServiceManagerAwareInterface
{
public function __construct()
{
parent::__construct('user_account_register');
$this->setHydrator(new ClassMethods())
->setInputFilter(new InputFilter());
$this->add(
array(
'name' => 'user',
'type' => 'User\Form\Fieldsets\UserFieldset',
'options' => array(
'use_as_base_fieldset' => true
)
)
);
}
public function setServiceManager(ServiceManager $serviceManager)
{
$this->get('user')
->setHydrator($serviceManager->get('entityHydrator'));
$filter = $this->getInputFilter();
// We need to add a few filters
$filter->get('user')
->add(
array(
'name' => 'email',
'validators' => array(
array(
'name' => 'callback',
'options' => array(
'callback' => function($fo) {
}
)
)
)
)
);
ob_clean();
var_dump($filter->get('user')->get('email')->getValidatorChain());
exit;
}
}
@awartoft
Copy link
Author

object(Zend\Validator\ValidatorChain)[718]
  protected 'plugins' => 
    object(Zend\Validator\ValidatorPluginManager)[719]
      protected 'invokableClasses' => 
        array (size=79)
          'alnum' => string 'Zend\I18n\Validator\Alnum' (length=25)
          'alpha' => string 'Zend\I18n\Validator\Alpha' (length=25)
          'barcodecode25interleaved' => string 'Zend\Validator\Barcode\Code25interleaved' (length=40)
          'barcodecode25' => string 'Zend\Validator\Barcode\Code25' (length=29)
          'barcodecode39ext' => string 'Zend\Validator\Barcode\Code39ext' (length=32)
          'barcodecode39' => string 'Zend\Validator\Barcode\Code39' (length=29)
          'barcodecode93ext' => string 'Zend\Validator\Barcode\Code93ext' (length=32)
          'barcodecode93' => string 'Zend\Validator\Barcode\Code93' (length=29)
          'barcodeean12' => string 'Zend\Validator\Barcode\Ean12' (length=28)
          'barcodeean13' => string 'Zend\Validator\Barcode\Ean13' (length=28)
          'barcodeean14' => string 'Zend\Validator\Barcode\Ean14' (length=28)
          'barcodeean18' => string 'Zend\Validator\Barcode\Ean18' (length=28)
          'barcodeean2' => string 'Zend\Validator\Barcode\Ean2' (length=27)
          'barcodeean5' => string 'Zend\Validator\Barcode\Ean5' (length=27)
          'barcodeean8' => string 'Zend\Validator\Barcode\Ean8' (length=27)
          'barcodegtin12' => string 'Zend\Validator\Barcode\Gtin12' (length=29)
          'barcodegtin13' => string 'Zend\Validator\Barcode\Gtin13' (length=29)
          'barcodegtin14' => string 'Zend\Validator\Barcode\Gtin14' (length=29)
          'barcodeidentcode' => string 'Zend\Validator\Barcode\Identcode' (length=32)
          'barcodeintelligentmail' => string 'Zend\Validator\Barcode\Intelligentmail' (length=38)
          'barcodeissn' => string 'Zend\Validator\Barcode\Issn' (length=27)
          'barcodeitf14' => string 'Zend\Validator\Barcode\Itf14' (length=28)
          'barcodeleitcode' => string 'Zend\Validator\Barcode\Leitcode' (length=31)
          'barcodeplanet' => string 'Zend\Validator\Barcode\Planet' (length=29)
          'barcodepostnet' => string 'Zend\Validator\Barcode\Postnet' (length=30)
          'barcoderoyalmail' => string 'Zend\Validator\Barcode\Royalmail' (length=32)
          'barcodesscc' => string 'Zend\Validator\Barcode\Sscc' (length=27)
          'barcodeupca' => string 'Zend\Validator\Barcode\Upca' (length=27)
          'barcodeupce' => string 'Zend\Validator\Barcode\Upce' (length=27)
          'barcode' => string 'Zend\Validator\Barcode' (length=22)
          'between' => string 'Zend\Validator\Between' (length=22)
          'callback' => string 'Zend\Validator\Callback' (length=23)
          'creditcard' => string 'Zend\Validator\CreditCard' (length=25)
          'csrf' => string 'Zend\Validator\Csrf' (length=19)
          'date' => string 'Zend\Validator\Date' (length=19)
          'datestep' => string 'Zend\Validator\DateStep' (length=23)
          'dbnorecordexists' => string 'Zend\Validator\Db\NoRecordExists' (length=32)
          'dbrecordexists' => string 'Zend\Validator\Db\RecordExists' (length=30)
          'digits' => string 'Zend\Validator\Digits' (length=21)
          'emailaddress' => string 'Zend\Validator\EmailAddress' (length=27)
          'explode' => string 'Zend\Validator\Explode' (length=22)
          'filecount' => string 'Zend\Validator\File\Count' (length=25)
          'filecrc32' => string 'Zend\Validator\File\Crc32' (length=25)
          'fileexcludeextension' => string 'Zend\Validator\File\ExcludeExtension' (length=36)
          'fileexcludemimetype' => string 'Zend\Validator\File\ExcludeMimeType' (length=35)
          'fileexists' => string 'Zend\Validator\File\Exists' (length=26)
          'fileextension' => string 'Zend\Validator\File\Extension' (length=29)
          'filefilessize' => string 'Zend\Validator\File\FilesSize' (length=29)
          'filehash' => string 'Zend\Validator\File\Hash' (length=24)
          'fileimagesize' => string 'Zend\Validator\File\ImageSize' (length=29)
          'fileiscompressed' => string 'Zend\Validator\File\IsCompressed' (length=32)
          'fileisimage' => string 'Zend\Validator\File\IsImage' (length=27)
          'filemd5' => string 'Zend\Validator\File\Md5' (length=23)
          'filemimetype' => string 'Zend\Validator\File\MimeType' (length=28)
          'filenotexists' => string 'Zend\Validator\File\NotExists' (length=29)
          'filesha1' => string 'Zend\Validator\File\Sha1' (length=24)
          'filesize' => string 'Zend\Validator\File\Size' (length=24)
          'fileupload' => string 'Zend\Validator\File\Upload' (length=26)
          'filewordcount' => string 'Zend\Validator\File\WordCount' (length=29)
          'float' => string 'Zend\I18n\Validator\Float' (length=25)
          'greaterthan' => string 'Zend\Validator\GreaterThan' (length=26)
          'hex' => string 'Zend\Validator\Hex' (length=18)
          'hostname' => string 'Zend\Validator\Hostname' (length=23)
          'iban' => string 'Zend\I18n\Validator\Iban' (length=24)
          'identical' => string 'Zend\Validator\Identical' (length=24)
          'inarray' => string 'Zend\Validator\InArray' (length=22)
          'int' => string 'Zend\I18n\Validator\Int' (length=23)
          'ip' => string 'Zend\Validator\Ip' (length=17)
          'isbn' => string 'Zend\Validator\Isbn' (length=19)
          'lessthan' => string 'Zend\Validator\LessThan' (length=23)
          'notempty' => string 'Zend\Validator\NotEmpty' (length=23)
          'postcode' => string 'Zend\I18n\Validator\PostCode' (length=28)
          'regex' => string 'Zend\Validator\Regex' (length=20)
          'sitemapchangefreq' => string 'Zend\Validator\Sitemap\Changefreq' (length=33)
          'sitemaplastmod' => string 'Zend\Validator\Sitemap\Lastmod' (length=30)
          'sitemaploc' => string 'Zend\Validator\Sitemap\Loc' (length=26)
          'sitemappriority' => string 'Zend\Validator\Sitemap\Priority' (length=31)
          'stringlength' => string 'Zend\Validator\StringLength' (length=27)
          'step' => string 'Zend\Validator\Step' (length=19)
      protected 'allowOverride' => boolean true
      protected 'creationOptions' => null
      protected 'serviceLocator' => null
      protected 'canonicalNames' => 
        array (size=1)
          'callback' => string 'callback' (length=8)
      protected 'factories' => 
        array (size=0)
          empty
      protected 'abstractFactories' => 
        array (size=0)
          empty
      protected 'pendingAbstractFactoryRequests' => 
        array (size=0)
          empty
      protected 'shared' => 
        array (size=0)
          empty
      protected 'instances' => 
        array (size=1)
          'callback' => 
            object(Zend\Validator\Callback)[721]
              ...
      protected 'aliases' => 
        array (size=0)
          empty
      protected 'initializers' => 
        array (size=1)
          0 => 
            object(Closure)[720]
              ...
      protected 'peeringServiceManagers' => 
        array (size=0)
          empty
      protected 'shareByDefault' => boolean true
      protected 'retrieveFromPeeringManagerFirst' => boolean false
      protected 'throwExceptionInCreate' => boolean true
  protected 'validators' => 
    array (size=3)
      0 => 
        array (size=2)
          'instance' => 
            object(Zend\Validator\Callback)[721]
              ...
          'breakChainOnFailure' => boolean false
      1 => 
        array (size=2)
          'instance' => 
            object(Zend\Validator\NotEmpty)[700]
              ...
          'breakChainOnFailure' => boolean false
      2 => 
        array (size=2)
          'instance' => 
            object(Zend\Validator\EmailAddress)[701]
              ...
          'breakChainOnFailure' => boolean false
  protected 'messages' => 
    array (size=0)
      empty
```cpde

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment