本文整理匯總了PHP中Zend\InputFilter\InputFilter::getInvalidInput方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter::getInvalidInput方法的具體用法?PHP InputFilter::getInvalidInput怎麽用?PHP InputFilter::getInvalidInput使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\InputFilter\InputFilter
的用法示例。
在下文中一共展示了InputFilter::getInvalidInput方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: getErrorMessages
/**
* Get error messages from the input filter
*
* @author Stoyan Rangelov
* @param \Zend\InputFilter\InputFilter $filter
* @return array
*/
public function getErrorMessages(\Zend\InputFilter\InputFilter $filter)
{
$errorMessages = array();
foreach ($filter->getInvalidInput() as $error) {
foreach ($error->getMessages() as $key => $value) {
$errorMessages[$error->getName()][$error->getName() . ucfirst($key)] = $value;
}
}
$result = array();
$result['status_code'] = 400;
$result['error_messages'] = $errorMessages;
return $result;
}
示例2: getErrorsFromInputFilter
/**
* Retrieve error messages from input filter.
*
* If the specific input object generating the message is tied to a Field,
* we will prefix the field's label to the error message to make it easier
* to understand.
*
* @return array
*/
public function getErrorsFromInputFilter()
{
$errors = array();
foreach ($this->inputFilter->getInvalidInput() as $id => $error) {
foreach ($error->getMessages() as $message) {
if (!$this->fields->has($id)) {
$errors[] = $message;
} else {
$field = $this->fields->get($id);
$this->fieldsWithErrors[] = $field->getControlName();
$errors[] = $field->getLabel() . ': ' . $message;
}
}
}
return $errors;
}