本文整理汇总了PHP中Tags::getMessages方法的典型用法代码示例。如果您正苦于以下问题:PHP Tags::getMessages方法的具体用法?PHP Tags::getMessages怎么用?PHP Tags::getMessages使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Tags
的用法示例。
在下文中一共展示了Tags::getMessages方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: createAction
/**
* Creates a new tag
*/
public function createAction()
{
if (!$this->request->isPost()) {
return $this->dispatcher->forward(array("controller" => "tags", "action" => "index"));
}
$tag = new Tags();
$tag->id = $this->request->getPost("id");
$tag->tag = $this->request->getPost("tag");
if (!$tag->save()) {
foreach ($tag->getMessages() as $message) {
$this->flash->error($message);
}
return $this->dispatcher->forward(array("controller" => "tags", "action" => "new"));
}
$this->flash->success("tag was created successfully");
return $this->dispatcher->forward(array("controller" => "tags", "action" => "index"));
}
示例2: newAction
public function newAction()
{
$response = new ApiResponse();
if ($this->request->isPost()) {
$tag = new Tags();
$tag->id = uniqid();
$tag->name = $this->request->getPost('name');
if ($this->request->hasFiles() == true) {
$baseLocation = 'files/';
foreach ($this->request->getUploadedFiles() as $file) {
$photos = new Photos();
$unique_filename = $tag->id;
$photos->size = $file->getSize();
$photos->original_name = $file->getName();
$photos->file_name = $unique_filename;
$photos->extension = $file->getExtension();
$location = $baseLocation . $unique_filename . "." . $file->getExtension();
$photos->public_link = $location;
try {
if (!$photos->save()) {
$response->setResponseError($photos->getMessages());
} else {
//Move the file into the application
$file->moveTo($location);
$tag->icon = $photos->public_link;
}
} catch (PDOException $e) {
$response->setResponseError($e->getMessage());
}
}
}
try {
if ($tag->save() == false) {
$response->setResponseError($tag->getMessages());
} else {
$response->setResponseMessage($tag->id);
}
} catch (PDOException $e) {
$response->setResponseError($e->getMessage());
}
} else {
$response->setResponseError('Wrong HTTP Method');
}
return $response;
}
示例3: foreach
* 3) Saving the imageTag
*/
foreach ($data as $tagRow) {
$name = $filter->sanitize($tagRow['name'], 'string');
//Get tag if it exists already
$tag = Tags::findFirst("name = '" . $name . "' AND category_id = '" . $tagRow['category_id'] . "'");
if (!$tag) {
$tag = new Tags();
}
$tag->name = $name;
$tag->category_id = $tagRow['category_id'];
//If the tag could not be saved, dump the error messages
if (!$tag->save()) {
echo 'could not save tag.';
var_dump($tagRow);
var_dump($tag->getMessages());
$app->response->setStatusCode('500');
$app->response->send();
}
$tag->refresh();
//Create an imageTag for each tag
$imagesTags = new ImagesTags();
$imagesTags->tag_id = $tag->id;
$imagesTags->image_id = $image->id;
$imagesTags->x = $tagRow['x'];
$imagesTags->y = $tagRow['y'];
$imagesTags->user_id = $user->getFbId();
//If the imageTag could not be saved, dump the error message
if (!$imagesTags->save()) {
var_dump($imagesTags->getMessages());
$app->response->setStatusCode('500');