Just some reorder of arguments..

This commit is contained in:
Matias De lellis
2020-09-19 14:23:33 -03:00
parent 5e076da22a
commit d002d7cf1e
3 changed files with 60 additions and 26 deletions

View File

@@ -134,14 +134,31 @@ class NoteApiController extends ApiController {
* @param int $id
* @param string $title
* @param string $content
* @param array $attachments
* @param string $color
* @param bool $isPinned
* @param array $tags
* @param array $sharedWith
* @param string $color
* @param array $attachments
*/
public function update(int $id, string $title, string $content, array $attachments, bool $isPinned, array $tags, array $sharedWith, string $color): JSONResponse {
$note = $this->noteService->update($this->userId, $id, $title, $content, $attachments, $isPinned, $tags, $sharedWith, $color);
public function update(int $id,
string $title,
string $content,
string $color,
bool $isPinned,
array $tags,
array $sharedWith,
array $attachments): JSONResponse
{
$note = $this->noteService->update($this->userId,
$id,
$title,
$content,
$color,
$isPinned,
$tags,
$sharedWith,
$attachments);
if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}

View File

@@ -126,14 +126,31 @@ class NoteController extends Controller {
* @param int $id
* @param string $title
* @param string $content
* @param array $attachments
* @param string $color
* @param bool $isPinned
* @param array $tags
* @param array $sharedWith
* @param string $color
* @param array $attachments
*/
public function update(int $id, string $title, string $content, array $attachments = [], bool $isPinned, array $tags = [], array $sharedWith = [], string $color): JSONResponse {
$note = $this->noteService->update($this->userId, $id, $title, $content, $attachments, $isPinned, $tags, $sharedWith, $color);
public function update(int $id,
string $title,
string $content,
string $color,
bool $isPinned,
array $tags,
array $sharedWith,
array $attachments): JSONResponse
{
$note = $this->noteService->update($this->userId,
$id,
$title,
$content,
$color,
$isPinned,
$tags,
$sharedWith,
$attachments);
if (is_null($note)) {
return new JSONResponse([], Http::STATUS_NOT_FOUND);
}

View File

@@ -197,7 +197,7 @@ class NoteService {
// Insert true color pin and tags to response
$newNote->setColor($hcolor->getColor());
$newNote->setIsPinned(false);
$newNote->setIsPinned($isPinned);
$newNote->setTags([]);
$newNote->setAttachts([]);
@@ -209,21 +209,21 @@ class NoteService {
* @param int $id
* @param string $title
* @param string $content
* @param array $attachts
* @param bool $pinned
* @param array $tags
* @param array $shares
* @param string $color
* @param bool $isPinned
* @param array $sharedWith
* @param array $tags
* @param array $attachments
*/
public function update(string $userId,
int $id,
string $title,
string $content,
array $attachts,
bool $pinned,
string $color,
bool $isPinned,
array $sharedWith,
array $tags,
array $shares,
string $color): ?Note
array $attachments): ?Note
{
// Get current Note and Color.
$note = $this->get($userId, $id);
@@ -257,7 +257,7 @@ class NoteService {
}
// Add new attachts
foreach ($attachts as $attach) {
foreach ($attachments as $attach) {
if (!$this->attachMapper->fileAttachExists($userId, $id, $attach['file_id'])) {
$hAttach = new Attach();
$hAttach->setUserId($userId);
@@ -284,7 +284,7 @@ class NoteService {
}
// Add new shares
foreach ($shares as $share) {
foreach ($sharedWith as $share) {
if (!$this->noteShareMapper->existsByNoteAndUser($id, $share['shared_user'])) {
$hShare = new NoteShare();
$hShare->setNoteId($id);
@@ -333,7 +333,7 @@ class NoteService {
// Set new info on Note
$note->setTitle($title);
$note->setContent($content);
$note->setPinned($pinned ? 1 : 0);
$note->setPinned($isPinned ? 1 : 0);
$note->setTimestamp(time());
$note->setColorId($hcolor->id);
@@ -342,7 +342,7 @@ class NoteService {
// Insert true color and pin to response
$newnote->setColor($hcolor->getColor());
$newnote->setIsPinned($note->getPinned() ? true : false);
$newnote->setIsPinned($isPinned);
// Fill new tags
$newnote->setTags($this->tagmapper->getTagsForNote($userId, $newnote->getId()));