Skip to content

Commit

Permalink
EZP-30382: Add content hide/reveal to REST API
Browse files Browse the repository at this point in the history
  • Loading branch information
ViniTou committed Sep 17, 2019
1 parent 199e931 commit 973edb6
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
20 changes: 20 additions & 0 deletions doc/specifications/rest/REST-API-V2.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1224,6 +1224,26 @@ In this example
<status>PUBLISHED</status>
</Content>
Hide Content
``````````````
:Resource: /content/objects/<ID>/hide
:Method: POST
:Description: The content is hidden.
:Response: 204
:Error Codes:
:404: content object was not found
:401: If the user is not authorized to hide this object

Reveal Content
``````````````
:Resource: /content/objects/<ID>/reveal
:Method: POST
:Description: The content is revealed.
:Response: 204
:Error Codes:
:404: content object was not found
:401: If the user is not authorized to reveal this object

Delete Content
``````````````
:Resource: /content/objects/<ID>
Expand Down
16 changes: 16 additions & 0 deletions eZ/Bundle/EzPublishRestBundle/Resources/config/routing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ ezpublish_rest_createDraftFromCurrentVersion:
requirements:
contentId: \d+

ezpublish_rest_hideContent:
path: /content/objects/{contentId}/hide
defaults:
_controller: ezpublish_rest.controller.content:hideContent
methods: [POST]
requirements:
contentId: \d+

ezpublish_rest_revealContent:
path: /content/objects/{contentId}/reveal
defaults:
_controller: ezpublish_rest.controller.content:revealContent
methods: [POST]
requirements:
contentId: \d+

# Binary content

ezpublish_rest_binaryContent_getImageVariation:
Expand Down
34 changes: 34 additions & 0 deletions eZ/Publish/Core/REST/Server/Controller/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,40 @@ public function createRelation($contentId, $versionNumber, Request $request)
);
}

/**
* @param int $contentId
*
* @return \eZ\Publish\Core\REST\Server\Values\NoContent
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
public function hideContent(int $contentId): Values\NoContent
{
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

$this->repository->getContentService()->hideContent($contentInfo);

return new Values\NoContent();
}

/**
* @param int $contentId
*
* @return \eZ\Publish\Core\REST\Server\Values\NoContent
*
* @throws \eZ\Publish\API\Repository\Exceptions\NotFoundException
* @throws \eZ\Publish\API\Repository\Exceptions\UnauthorizedException
*/
public function revealContent(int $contentId): Values\NoContent
{
$contentInfo = $this->repository->getContentService()->loadContentInfo($contentId);

$this->repository->getContentService()->revealContent($contentInfo);

return new Values\NoContent();
}

/**
* Creates and executes a content view.
*
Expand Down

0 comments on commit 973edb6

Please sign in to comment.