Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EZP-30382: Add content hide/reveal to REST API #2767

Merged
merged 1 commit into from
Sep 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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