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


PHP Zend_Filter_Input::getMissing方法代码示例

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


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

示例1: testTranslateNotEmptyMessagesByUsingRegistry

 /**
  * @group ZF-3736
  */
 public function testTranslateNotEmptyMessagesByUsingRegistry()
 {
     require_once 'Zend/Translate/Adapter/Array.php';
     $translator = new Zend_Translate_Adapter_Array(array('missingMessage' => 'Still missing'), 'en');
     require_once 'Zend/Registry.php';
     Zend_Registry::set('Zend_Translate', $translator);
     $validators = array('rule1' => array('presence' => 'required', 'fields' => array('field1', 'field2'), 'default' => array('field1default')));
     $data = array();
     $input = new Zend_Filter_Input(null, $validators, $data);
     $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return true');
     $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false');
     $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
     $this->assertFalse($input->hasValid(), 'Expected hasValid() to return false');
     $missing = $input->getMissing();
     $this->assertType('array', $missing);
     $this->assertEquals(array('rule1'), array_keys($missing));
     $this->assertEquals(array("Still missing"), $missing['rule1']);
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:21,代码来源:InputTest.php

示例2: testOptionPresence

 public function testOptionPresence()
 {
     $data = array('field1' => '123');
     $validators = array('field1' => 'Digits', 'field2' => 'Digits');
     $options = array(Zend_Filter_Input::PRESENCE => true);
     $input = new Zend_Filter_Input(null, $validators, $data, $options);
     $this->assertTrue($input->hasMissing(), 'Expected hasMissing() to return false');
     $this->assertFalse($input->hasInvalid(), 'Expected hasInvalid() to return false');
     $this->assertFalse($input->hasUnknown(), 'Expected hasUnknown() to return false');
     $this->assertTrue($input->hasValid(), 'Expected hasValid() to return true');
     $missing = $input->getMissing();
     $this->assertType('array', $missing);
     $this->assertEquals(array('field2'), array_keys($missing));
     $this->assertEquals("Field 'field2' is required by rule 'field2', but the field is missing", $missing['field2'][0]);
 }
开发者ID:jorgenils,项目名称:zend-framework,代码行数:15,代码来源:InputTest.php

示例3: fromFilter

 /**
  * Creates a Conjoon_Error_Form based on the fields that where marked as
  * errorneous in the passed filter-instance.
  *
  * @param Zend_Filter_Input $filter
  * @param Zend_Filter_Exception $e
  *
  * @return Conjoon_Error_Form
  */
 public static function fromFilter(Zend_Filter_Input $filter, Zend_Filter_Exception $e)
 {
     $error = self::fromException($e, 'Conjoon_Error_Form');
     $fields = array();
     if ($filter->hasMissing()) {
         foreach ($filter->getMissing() as $f => $mes) {
             $fields[$f] = array_values($mes);
         }
     } else {
         if ($filter->hasInvalid()) {
             foreach ($filter->getInvalid() as $f => $mes) {
                 $fields[$f] = array_values($mes);
             }
         }
     }
     $error->setMessage("Error in user input. The following fields " . "where missing or contained invalid data: " . implode('; ', array_keys($fields)));
     $error->setLevel(self::LEVEL_WARNING);
     $error->setFields($fields);
     return $error;
 }
开发者ID:ThorstenSuckow,项目名称:conjoon,代码行数:29,代码来源:Error.php


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