当前位置: 首页>>代码示例>>PHP>>正文


PHP Input::setFilterChain方法代码示例

本文整理汇总了PHP中Zend\InputFilter\Input::setFilterChain方法的典型用法代码示例。如果您正苦于以下问题:PHP Input::setFilterChain方法的具体用法?PHP Input::setFilterChain怎么用?PHP Input::setFilterChain使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Zend\InputFilter\Input的用法示例。


在下文中一共展示了Input::setFilterChain方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testCanInjectFilterChain

 public function testCanInjectFilterChain()
 {
     $input = new Input('foo');
     $chain = new Filter\FilterChain();
     $input->setFilterChain($chain);
     $this->assertSame($chain, $input->getFilterChain());
 }
开发者ID:razvansividra,项目名称:pnlzf2-1,代码行数:7,代码来源:InputTest.php

示例2: __construct

 public function __construct()
 {
     $title = new Input('title');
     $title->setRequired(true);
     $title->setValidatorChain($this->getTitleValidatorChain());
     $title->setFilterChain($this->getStringTrimFilterChain());
     $slug = new Input('slug');
     $slug->setRequired(true);
     $slug->setValidatorChain($this->getSlugValidatorChain());
     $slug->setFilterChain($this->getStringTrimFilterChain());
     $content = new Input('content');
     $content->setRequired(true);
     $content->setValidatorChain($this->getContentValidatorChain());
     $content->setFilterChain($this->getStringTrimFilterChain());
     $this->add($title);
     $this->add($slug);
     $this->add($content);
 }
开发者ID:samija,项目名称:Deeplifec4tk,代码行数:18,代码来源:AddPost.php

示例3: createAttributesElements

 /**
  * Prepare the attribute form
  *
  * @param $attributes array           
  * @return \ProductAdmin\Form\ProductForm
  */
 public function createAttributesElements(array $attributes)
 {
     $customHydrator = new ClassMethods(true);
     $parentFilter = new \Zend\InputFilter\InputFilter();
     $fieldset = new \Zend\Form\Fieldset('attributes');
     //         $fieldset->setUseAsBaseFieldset(true);
     $fieldset->setObject(new \Zend\Stdlib\ArrayObject());
     $fieldset->setFormFactory($this->getFormFactory());
     // thanks to jurians #zftalk irc
     $fieldInput = null;
     $inputFilter = new \Zend\InputFilter\InputFilter();
     foreach ($attributes as $attribute) {
         $formitem = array();
         $filterChain = new \Zend\Filter\FilterChain();
         $name = $attribute->getName();
         $label = $attribute->getLabel() ? $attribute->getLabel() : "-";
         $type = $attribute->getType() ? $attribute->getType() : "string";
         $isRequired = $attribute->getIsRequired();
         $sourceModel = $attribute->getSourceModel();
         $filters = $attribute->getFilters();
         $validators = $attribute->getValidators();
         $cssStyles = $attribute->getCss();
         $validators = !empty($validators) ? json_decode($validators, true) : array();
         // create the new form element array structure
         $formitem['attributes'] = $attribute->getCustomAttributes() ? json_decode($attribute->getCustomAttributes(), true) : json_decode($attribute->attributes, true);
         $formitem['attributes']['id'] = $name;
         $formitem['attributes']['class'] = !empty($attribute->basecss) ? $attribute->basecss : null;
         $formitem['attributes']['name'] = $name;
         $formitem['type'] = !empty($sourceModel) ? $sourceModel : $attribute->input_type;
         $formitem['options']['label'] = $label;
         if ($attribute->getData()) {
             $formitem['options']['value_options'] = json_decode($attribute->getData(), true);
         }
         $filterChain->attachByName('null');
         // set as default
         // set the css style of the element
         if (!empty($cssStyles)) {
             $formitem['attributes']['class'] .= " " . $cssStyles;
         }
         // Handle the dates
         if (!empty($type) && $type == "date") {
             $customHydrator->addStrategy($name, new DateTimeStrategy());
             $typeSource = 'Zend\\Form\\Element\\Date';
             $formitem['type'] = "\\Zend\\Form\\Element\\Date";
             $formitem['options']['format'] = 'd/m/Y';
         }
         // handle the validators preferences of the attribute
         foreach ($validators as $validator) {
             $formitem['validators'] = $validator;
         }
         // var_dump($type);
         // var_dump($customHydrator);
         //             var_dump($formitem);
         // Attach the form item into the form
         $fieldset->add($formitem);
         $fieldInput = new \Zend\InputFilter\Input($name);
         $fieldInput->setRequired($isRequired);
         // handle the filters preferences of the attribute
         if (!empty($filters)) {
             // get the filters attached to the attribute
             $filters = json_decode($filters, true);
             foreach ($filters as $filter) {
                 // if the filter is an array check it by name
                 if (is_array($filter)) {
                     // If the filter is a ...
                     if ($filter['name'] == "File\\RenameUpload") {
                         // create the filter Zend\InputFilter\FileInput
                         $thefilter = new \Zend\InputFilter\FileInput($filter['options']);
                         // ... but how to attach the new filter to the
                         // chain?
                         $chain = new \Zend\Filter\FilterChain();
                         // ... in this way it doesn't work!!
                         $chain->attachByName("filerenameupload", $filter['options']);
                         $filterChain->merge($chain);
                         // just for debugging it ...
                         $filtersApplied = $filterChain->getFilters();
                         //                             var_dump($filtersApplied->toArray());
                     }
                 } elseif ($filter == "cleanurl") {
                     // custom filter
                     $filterChain->attach(new \ProductAdmin\Form\Filter\Cleanurl());
                 } elseif (is_string($filter)) {
                     $filterChain->attachByName($filter);
                 }
             }
         }
         $fieldInput->setFilterChain($filterChain);
         $inputFilter->add($fieldInput);
     }
     $fieldset->setHydrator($customHydrator);
     $this->add($fieldset);
     $parentFilter->add($inputFilter, 'attributes');
     // thanks to GeeH #zftalk irc
     $this->setInputFilter($parentFilter);
//.........这里部分代码省略.........
开发者ID:eotg1910,项目名称:shineisp2,代码行数:101,代码来源:ProductForm.php


注:本文中的Zend\InputFilter\Input::setFilterChain方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。