本文整理匯總了PHP中app\Item::setUser方法的典型用法代碼示例。如果您正苦於以下問題:PHP Item::setUser方法的具體用法?PHP Item::setUser怎麽用?PHP Item::setUser使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類app\Item
的用法示例。
在下文中一共展示了Item::setUser方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: edit
public function edit(Request $request, Response $response, array $args)
{
$template = new \App\Template('form.twig');
$template->title = 'Create';
// Date granularities.
$sql = "SELECT id, title FROM date_granularities ORDER BY id ASC";
$template->date_granularities = $this->db->query($sql)->fetchAll();
// Item.
$item = new Item();
if (isset($args['id'])) {
$template->title = 'Editing #' . $args['id'];
$item = new Item($args['id']);
}
$template->item = $item;
// User.
$item->setUser($this->user);
if (!$this->user->getId()) {
$msg = 'You have to ' . ' <a href="' . $this->config->baseUrl() . '/login" class="alert-link">log in</a> ' . ' before you can add or edit items.';
$template->alert('info', $msg);
$response->setContent($template->render());
return $response;
}
$template->groups = $this->user->getGroups();
// Other template data.
$template->fileContents = $item->getFileContents();
$template->itemTags = $item->getTagsString();
$template->itemReadGroupId = $item->getReadGroup()->id;
$template->itemEditGroupId = $item->getEditGroup()->id;
$response->setContent($template->render());
return $response;
}