本文整理匯總了PHP中Zend\InputFilter\InputFilter::getValues方法的典型用法代碼示例。如果您正苦於以下問題:PHP InputFilter::getValues方法的具體用法?PHP InputFilter::getValues怎麽用?PHP InputFilter::getValues使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Zend\InputFilter\InputFilter
的用法示例。
在下文中一共展示了InputFilter::getValues方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: validate
/**
* Validates the form data using the provided input filter.
*
* If validation errors are found, the form is populated with the corresponding error messages.
* Form values are updated with the clean values provided by the filter.
*
* @param Form $form
* @return boolean
*/
public function validate(Form $form)
{
$this->inputFilter->setData($form->values());
if (!($isValid = $this->inputFilter->isValid())) {
$form->setErrorMessages($this->inputFilter->getMessages());
return $isValid;
}
$form->submit($this->inputFilter->getValues());
return $isValid;
}
示例2: uploadImageAction
public function uploadImageAction()
{
$this->checkAuth();
$request = $this->getRequest();
if ($request->isPost()) {
// File upload input
$file = new FileInput('avatar');
// Special File Input type
$file->getValidatorChain()->attach(new Validator\File\UploadFile());
$file->getFilterChain()->attach(new Filter\File\RenameUpload(array('target' => './public/files/users/avatar/origin/', 'use_upload_name' => true, 'randomize' => true)));
// Merge $_POST and $_FILES data together
$request = new Request();
$postData = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$inputFilter = new InputFilter();
$inputFilter->add($file)->setData($postData);
if ($inputFilter->isValid()) {
// FileInput validators are run, but not the filters...
$data = $inputFilter->getValues();
// This is when the FileInput filters are run.
$avatar = basename($data['avatar']['tmp_name']);
$this->databaseService->updateAvatar($this->user->id, $avatar);
$this->user->avatar = $avatar;
} else {
// error
}
}
return $this->redirect()->toRoute('profile');
}
示例3: addfileAction
public function addfileAction()
{
$this->checkAuth();
$request = $this->getRequest();
if ($request->isPost()) {
$file_attach = new FileAttachment();
$file_attach->user_create = $this->auth->getIdentity()->id;
$file_attach->date_create = date('Y-m-d H:i:s');
$file_attach->last_date = $file_attach->date_create;
$file_attach->last_user = $this->auth->getIdentity()->id;
// info pay
$file_attach->task_id = $request->getPost('task_id');
$file_attach->permission_option = $request->getPost('permission_option');
if ($this->isLevel2() != true) {
$permission = $this->databaseService->getPermissionUser($file_attach->task_id, $file_attach->user_create);
if ($permission == Config::FILE_PERMISSION_ERROR) {
return new JsonModel(array());
}
if ($permission == Config::FILE_PERMISSION_CUSTUMER) {
$file_attach->permission_option = Config::FILE_PERMISSION_CUSTUMER;
}
if ($permission == Config::FILE_PERMISSION_PROVIDER) {
$file_attach->permission_option = Config::FILE_PERMISSION_PROVIDER;
}
}
// File upload input
$file = new FileInput('file_name');
// Special File Input type
$file->getValidatorChain()->attach(new Validator\File\UploadFile());
$file->getFilterChain()->attach(new Filter\File\RenameUpload(array('target' => '.' . Config::FILE_ATTACHMENT_PATH . $file_attach->task_id, 'use_upload_name' => true, 'randomize' => true)));
if (!file_exists('.' . Config::FILE_ATTACHMENT_PATH . $file_attach->task_id)) {
mkdir('.' . Config::FILE_ATTACHMENT_PATH . $file_attach->task_id, 0700, true);
}
// Merge $_POST and $_FILES data together
$request = new Request();
$postData = array_merge_recursive($request->getPost()->toArray(), $request->getFiles()->toArray());
$inputFilter = new InputFilter();
$inputFilter->add($file)->setData($postData);
if ($inputFilter->isValid()) {
// FileInput validators are run, but not the filters...
$data = $inputFilter->getValues();
// This is when the FileInput filters are run.
$file_attach->real_name = basename($data['file_name']['tmp_name']);
$file_attach->file_name = basename($data['file_name']['name']);
$result = $this->databaseService->addFileAttachment($file_attach);
$file_attach->id = $result->getGeneratedValue();
$this->databaseService->addFileLog($this->auth->getIdentity()->id, $file_attach, Config::PAY_INFO_COMMON);
}
}
return new JsonModel(array());
}
示例4: getValues
/**
* Return a list of filtered values.
*
* @return array|null
*/
public function getValues()
{
// When there's no data and the filter itself is not required,
// we don't return values
if (!$this->data && !$this->isRequired()) {
return null;
}
// Don't return any values when "inputsToFilter" is set to empty array
if (!$this->needsFiltering()) {
return array();
}
return parent::getValues();
}
示例5: getValues
/**
* {@inheritDoc}
*/
public function getValues()
{
$values = parent::getValues();
$filter = $this->getFilterChain();
$this->bindClosureFilter($filter);
return $filter->filter($values);
}
示例6: getValues
/**
* @return array
*/
public function getValues()
{
$values = parent::getValues();
foreach ($this->nestedInputFilters as $name => $nestedInputFilter) {
$values += [
$name => $nestedInputFilter->getValues()
];
}
return $values;
}