mirror of
https://github.com/wallabag/wallabag.git
synced 2024-11-27 11:31:05 +00:00
PATCH method, boolean for some parameters and change entity methods name
This commit is contained in:
parent
c2e2906c8d
commit
2c093b03de
2 changed files with 40 additions and 13 deletions
|
@ -17,9 +17,9 @@ class WallabagRestController extends Controller
|
||||||
*
|
*
|
||||||
* @ApiDoc(
|
* @ApiDoc(
|
||||||
* parameters={
|
* parameters={
|
||||||
* {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by archived status."},
|
* {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by archived status."},
|
||||||
* {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', all entries by default", "description"="filter by starred status."},
|
* {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false, all entries by default", "description"="filter by starred status."},
|
||||||
* {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="filter by deleted status."},
|
* {"name"="delete", "dataType"="boolean", "required"=false, "format"="true or false, default '0'", "description"="filter by deleted status."},
|
||||||
* {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."},
|
* {"name"="sort", "dataType"="string", "required"=false, "format"="'created' or 'updated', default 'created'", "description"="sort entries by date."},
|
||||||
* {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
|
* {"name"="order", "dataType"="string", "required"=false, "format"="'asc' or 'desc', default 'desc'", "description"="order of sort."},
|
||||||
* {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."},
|
* {"name"="page", "dataType"="integer", "required"=false, "format"="default '1'", "description"="what page you want."},
|
||||||
|
@ -109,14 +109,41 @@ class WallabagRestController extends Controller
|
||||||
* parameters={
|
* parameters={
|
||||||
* {"name"="title", "dataType"="string", "required"=false},
|
* {"name"="title", "dataType"="string", "required"=false},
|
||||||
* {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
|
* {"name"="tags", "dataType"="string", "required"=false, "format"="tag1,tag2,tag3", "description"="a comma-separated list of tags."},
|
||||||
* {"name"="archive", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="archived the entry."},
|
* {"name"="archive", "dataType"="boolean", "required"=false, "format"="true or false", "description"="archived the entry."},
|
||||||
* {"name"="star", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="starred the entry."},
|
* {"name"="star", "dataType"="boolean", "required"=false, "format"="true or false", "description"="starred the entry."},
|
||||||
* {"name"="delete", "dataType"="integer", "required"=false, "format"="'0' or '1', default '0'", "description"="flag as deleted. Default false. In case that you don't want to *really* remove it.."},
|
* {"name"="delete", "dataType"="boolean", "required"=false, "format"="true or false", "description"="flag as deleted. Default false. In case that you don't want to *really* remove it.."},
|
||||||
* }
|
* }
|
||||||
* )
|
* )
|
||||||
*/
|
*/
|
||||||
public function patchEntriesAction(Entries $entry)
|
public function patchEntriesAction(Entries $entry, Request $request)
|
||||||
{
|
{
|
||||||
|
$title = $request->request->get("title");
|
||||||
|
$tags = $request->request->get("tags", array());
|
||||||
|
$isArchived = $request->request->get("archive");
|
||||||
|
$isDeleted = $request->request->get("delete");
|
||||||
|
$isStarred = $request->request->get("star");
|
||||||
|
|
||||||
|
if (!is_null($title)) {
|
||||||
|
$entry->setTitle($title);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($isArchived)) {
|
||||||
|
$entry->setRead($isArchived);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($isDeleted)) {
|
||||||
|
$entry->setDeleted($isDeleted);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!is_null($isStarred)) {
|
||||||
|
$entry->setFav($isStarred);
|
||||||
|
}
|
||||||
|
|
||||||
|
$em = $this->getDoctrine()->getManager();
|
||||||
|
$em->persist($entry);
|
||||||
|
$em->flush();
|
||||||
|
|
||||||
|
return $entry;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -185,7 +185,7 @@ class Entries
|
||||||
* @param string $isRead
|
* @param string $isRead
|
||||||
* @return Entries
|
* @return Entries
|
||||||
*/
|
*/
|
||||||
public function setIsRead($isRead)
|
public function setRead($isRead)
|
||||||
{
|
{
|
||||||
$this->isRead = $isRead;
|
$this->isRead = $isRead;
|
||||||
|
|
||||||
|
@ -197,7 +197,7 @@ class Entries
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIsRead()
|
public function isRead()
|
||||||
{
|
{
|
||||||
return $this->isRead;
|
return $this->isRead;
|
||||||
}
|
}
|
||||||
|
@ -215,7 +215,7 @@ class Entries
|
||||||
* @param string $isFav
|
* @param string $isFav
|
||||||
* @return Entries
|
* @return Entries
|
||||||
*/
|
*/
|
||||||
public function setIsFav($isFav)
|
public function setFav($isFav)
|
||||||
{
|
{
|
||||||
$this->isFav = $isFav;
|
$this->isFav = $isFav;
|
||||||
|
|
||||||
|
@ -227,7 +227,7 @@ class Entries
|
||||||
*
|
*
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
public function getIsFav()
|
public function isFav()
|
||||||
{
|
{
|
||||||
return $this->isFav;
|
return $this->isFav;
|
||||||
}
|
}
|
||||||
|
@ -402,7 +402,7 @@ class Entries
|
||||||
/**
|
/**
|
||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
public function isIsPublic()
|
public function isPublic()
|
||||||
{
|
{
|
||||||
return $this->isPublic;
|
return $this->isPublic;
|
||||||
}
|
}
|
||||||
|
@ -410,7 +410,7 @@ class Entries
|
||||||
/**
|
/**
|
||||||
* @param boolean $isPublic
|
* @param boolean $isPublic
|
||||||
*/
|
*/
|
||||||
public function setIsPublic($isPublic)
|
public function setPublic($isPublic)
|
||||||
{
|
{
|
||||||
$this->isPublic = $isPublic;
|
$this->isPublic = $isPublic;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue