-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathContentDeleteController.php
65 lines (60 loc) · 2.01 KB
/
ContentDeleteController.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<?php
/**
* @copyright Copyright (C) Ibexa AS. All rights reserved.
* @license For full copyright and license information view LICENSE file distributed with this source code.
*/
namespace Ibexa\Rest\Server\Controller\Content;
use ApiPlatform\Metadata\Delete;
use ApiPlatform\OpenApi\Model;
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Values;
use Symfony\Component\HttpFoundation\Response;
#[Delete(
uriTemplate: '/content/objects/{contentId}',
openapi: new Model\Operation(
summary: 'Delete Content',
description: 'Deletes content item. If content item has multiple Locations, all of them will be deleted via delete a subtree.',
tags: [
'Objects',
],
parameters: [
new Model\Parameter(
name: 'contentId',
in: 'path',
required: true,
schema: [
'type' => 'string',
],
),
],
responses: [
Response::HTTP_NO_CONTENT => [
'description' => 'The content item is deleted.',
],
Response::HTTP_NOT_FOUND => [
'description' => 'Error - content item was not found.',
],
Response::HTTP_UNAUTHORIZED => [
'description' => 'Error - the user is not authorized to delete this content item.',
],
],
),
)]
class ContentDeleteController extends RestController
{
/**
* The content is deleted. If the content has locations (which is required in 4.x)
* on delete all locations assigned the content object are deleted via delete subtree.
*
* @param mixed $contentId
*
* @return \Ibexa\Rest\Server\Values\NoContent
*/
public function deleteContent($contentId)
{
$this->repository->getContentService()->deleteContent(
$this->repository->getContentService()->loadContentInfo($contentId)
);
return new Values\NoContent();
}
}