本文整理汇总了PHP中FileModel::write方法的典型用法代码示例。如果您正苦于以下问题:PHP FileModel::write方法的具体用法?PHP FileModel::write怎么用?PHP FileModel::write使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileModel
的用法示例。
在下文中一共展示了FileModel::write方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: serverPropsFormSubmitted
/**
*
* @param \Nette\Application\UI\Form $form
*/
public function serverPropsFormSubmitted(Form $form)
{
if ($this->allowedToEdit) {
$content = $form->getValues()->props;
$data = $this->fileModel->checkUnchangeableLines($content, $this->unchangeableLines);
$this->fileModel->write($data, $this->filePath);
$this->getPresenter()->flashMessage('Nastavení aktualizováno.', 'success');
} else {
$this->flashMessage('Nemáte právo editovat nastavení.', 'error');
}
if ($this->getPresenter()->isAjax()) {
$this->getPresenter()->redrawControl();
} else {
$this->getPresenter()->redirect('this');
}
}
示例2: writeOpsToFile
/**
* Call only when server is NOT running
* @param int $serverId
* @param boolean TRUE if you want to delete op, FALSE if you want to add op
*/
private function writeOpsToFile($serverId, $delete)
{
$path = $this->serverRepo->getPath($serverId);
$db = $this->readOpsFromDb($serverId);
if ($delete == TRUE) {
$write = $db;
} else {
$file = $this->readOpsFromFile($path, 'ops.json');
$merge = array_merge($db, $file);
$write = array_unique($merge, SORT_REGULAR);
}
$this->fileModel->write(json_encode($write, JSON_PRETTY_PRINT), $path . 'ops.json', TRUE);
}