本文整理汇总了PHP中Grav\Common\Utils::arrayFlatten方法的典型用法代码示例。如果您正苦于以下问题:PHP Utils::arrayFlatten方法的具体用法?PHP Utils::arrayFlatten怎么用?PHP Utils::arrayFlatten使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Grav\Common\Utils
的用法示例。
在下文中一共展示了Utils::arrayFlatten方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onPagesInitialized
/**
* Initialize form if the page has one. Also catches form processing if user posts the form.
*/
public function onPagesInitialized()
{
$submitted = false;
if ($this->isAdmin() && !empty($_POST)) {
$page = $this->grav['page'];
if (!$page) {
return;
}
$header = $page->header();
if (isset($header->form) && is_array($header->form)) {
$this->active = true;
// Create form
$this->form = new Form($page);
$this->enable(['onFormProcessed' => ['onFormProcessed', 0], 'onFormValidationError' => ['onFormValidationError', 0]]);
$this->form->post();
}
} elseif ($this->forms) {
$this->enable(['onTwigPageVariables' => ['onTwigVariables', 0], 'onTwigSiteVariables' => ['onTwigVariables', 0], 'onFormFieldTypes' => ['onFormFieldTypes', 0]]);
// Regenerate list of flat_forms if not already populated
if (empty($this->flat_forms)) {
$this->flat_forms = Utils::arrayFlatten($this->forms);
}
// Save the current state of the forms to cache
if ($this->recache_forms) {
$this->grav['cache']->save($this->cache_id, [$this->forms, $this->flat_forms]);
}
$this->active = true;
// Handle posting if needed.
if (!empty($_POST)) {
$this->enable(['onFormProcessed' => ['onFormProcessed', 0], 'onFormValidationError' => ['onFormValidationError', 0]]);
$current_form_name = $this->getFormName($this->grav['page']);
$this->json_response = [];
if ($form = $this->getFormByName($current_form_name)) {
if ($this->grav['uri']->extension() === 'json') {
$this->json_response = $form->uploadFiles();
} else {
$form->post();
$submitted = true;
}
} elseif (isset($this->grav['page']->header()->form)) {
$form = new Form($this->grav['page']);
$form->post();
$submitted = true;
}
}
// Clear flash objects for previously uploaded files
// whenever the user switches page / reloads
// ignoring any JSON / extension call
if (is_null($this->grav['uri']->extension()) && !$submitted) {
// Discard any previously uploaded files session.
// and if there were any uploaded file, remove them from the filesystem
if ($flash = $this->grav['session']->getFlashObject('files-upload')) {
$flash = new \RecursiveIteratorIterator(new \RecursiveArrayIterator($flash));
foreach ($flash as $key => $value) {
if ($key !== 'tmp_name') {
continue;
}
@unlink($value);
}
}
}
}
}