mirror of
https://github.com/JanGross/quicknotes.git
synced 2025-11-30 23:37:16 +01:00
Can create the notes with more optional parameters
This commit is contained in:
@@ -96,9 +96,27 @@ class NoteApiController extends ApiController {
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $color
|
* @param string $color
|
||||||
|
* @param bool $isPinned
|
||||||
|
* @param array $sharedWith
|
||||||
|
* @param array $tags
|
||||||
|
* @param array $attachments
|
||||||
*/
|
*/
|
||||||
public function create(string $title, string $content, string $color = null) {
|
public function create(string $title,
|
||||||
$note = $this->noteService->create($this->userId, $title, $content, $color);
|
string $content,
|
||||||
|
string $color = null,
|
||||||
|
bool $isPinned = false,
|
||||||
|
array $sharedWith = [],
|
||||||
|
array $tags = [],
|
||||||
|
array $attachments = [])
|
||||||
|
{
|
||||||
|
$note = $this->noteService->create($this->userId,
|
||||||
|
$title,
|
||||||
|
$content,
|
||||||
|
$color,
|
||||||
|
$isPinned,
|
||||||
|
$sharedWith,
|
||||||
|
$tags,
|
||||||
|
$attachments);
|
||||||
|
|
||||||
$etag = md5(json_encode($note));
|
$etag = md5(json_encode($note));
|
||||||
|
|
||||||
|
|||||||
@@ -90,9 +90,27 @@ class NoteController extends Controller {
|
|||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $color
|
* @param string $color
|
||||||
|
* @param bool $isPinned
|
||||||
|
* @param array $sharedWith
|
||||||
|
* @param array $tags
|
||||||
|
* @param array $attachments
|
||||||
*/
|
*/
|
||||||
public function create(string $title, string $content, string $color = null) {
|
public function create(string $title,
|
||||||
$note = $this->noteService->create($this->userId, $title, $content, $color);
|
string $content,
|
||||||
|
string $color = null,
|
||||||
|
bool $isPinned = false,
|
||||||
|
array $sharedWith = [],
|
||||||
|
array $tags = [],
|
||||||
|
array $attachments = [])
|
||||||
|
{
|
||||||
|
$note = $this->noteService->create($this->userId,
|
||||||
|
$title,
|
||||||
|
$content,
|
||||||
|
$color,
|
||||||
|
$isPinned,
|
||||||
|
$sharedWith,
|
||||||
|
$tags,
|
||||||
|
$attachments);
|
||||||
|
|
||||||
$etag = md5(json_encode($note));
|
$etag = md5(json_encode($note));
|
||||||
|
|
||||||
|
|||||||
@@ -152,9 +152,21 @@ class NoteService {
|
|||||||
* @param string $userId
|
* @param string $userId
|
||||||
* @param string $title
|
* @param string $title
|
||||||
* @param string $content
|
* @param string $content
|
||||||
* @param string $color
|
* @param string $color optional color.
|
||||||
|
* @param bool $isPinned optional if note must be pinned
|
||||||
|
* @param array $sharedWith optional list of shares
|
||||||
|
* @param array $tags optional list of tags
|
||||||
|
* @param array $attachments optional list of attachments
|
||||||
*/
|
*/
|
||||||
public function create(string $userId, string $title, string $content, string $color = NULL): Note {
|
public function create(string $userId,
|
||||||
|
string $title,
|
||||||
|
string $content,
|
||||||
|
string $color = null,
|
||||||
|
bool $isPinned = false,
|
||||||
|
array $sharedWith = [],
|
||||||
|
array $tags = [],
|
||||||
|
array $attachments = []): ?Note
|
||||||
|
{
|
||||||
if (is_null($color)) {
|
if (is_null($color)) {
|
||||||
$color = $this->settingsService->getColorForNewNotes();
|
$color = $this->settingsService->getColorForNewNotes();
|
||||||
}
|
}
|
||||||
@@ -168,17 +180,21 @@ class NoteService {
|
|||||||
$hcolor = $this->colormapper->insert($hcolor);
|
$hcolor = $this->colormapper->insert($hcolor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// Create note and insert it
|
// Create note and insert it
|
||||||
$note = new Note();
|
$note = new Note();
|
||||||
|
|
||||||
$note->setTitle($title);
|
$note->setTitle($title);
|
||||||
$note->setContent($content);
|
$note->setContent($content);
|
||||||
|
$note->setPinned($isPinned ? 1 : 0);
|
||||||
$note->setTimestamp(time());
|
$note->setTimestamp(time());
|
||||||
$note->setColorId($hcolor->id);
|
$note->setColorId($hcolor->id);
|
||||||
$note->setUserId($userId);
|
$note->setUserId($userId);
|
||||||
|
|
||||||
$newNote = $this->notemapper->insert($note);
|
$newNote = $this->notemapper->insert($note);
|
||||||
|
|
||||||
|
// TODO: Insert optional shares, tags and attachments.
|
||||||
|
|
||||||
// Insert true color pin and tags to response
|
// Insert true color pin and tags to response
|
||||||
$newNote->setColor($hcolor->getColor());
|
$newNote->setColor($hcolor->getColor());
|
||||||
$newNote->setIsPinned(false);
|
$newNote->setIsPinned(false);
|
||||||
|
|||||||
Reference in New Issue
Block a user