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

[stable0.7] fix(Controller): remove unneeded endpoints #1133

Merged
merged 1 commit into from
Jun 10, 2024
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
2 changes: 0 additions & 2 deletions appinfo/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -137,8 +137,6 @@
['name' => 'Context#update', 'url' => '/api/2/contexts/{contextId}', 'verb' => 'PUT'],
['name' => 'Context#destroy', 'url' => '/api/2/contexts/{contextId}', 'verb' => 'DELETE'],
['name' => 'Context#transfer', 'url' => '/api/2/contexts/{contextId}/transfer', 'verb' => 'PUT'],
['name' => 'Context#addNode', 'url' => '/api/2/contexts/{contextId}/nodes', 'verb' => 'POST'],
['name' => 'Context#removeNode', 'url' => '/api/2/contexts/{contextId}/nodes/{nodeRelId}', 'verb' => 'DELETE'],
['name' => 'Context#updateContentOrder', 'url' => '/api/2/contexts/{contextId}/pages/{pageId}', 'verb' => 'PUT'],
]
];
70 changes: 0 additions & 70 deletions lib/Controller/ContextController.php
Original file line number Diff line number Diff line change
Expand Up @@ -235,76 +235,6 @@ public function transfer(int $contextId, string $newOwnerId, int $newOwnerType =
}
}

/**
* [api v2] Add a node to a Context
*
* @param int $contextId ID of the context
* @param int $nodeId ID of the node
* @param int $nodeType any Application::NODE_TYPE_* constant
* @param int $permissions bitmask of the permissions for context recipients
* @param ?int $order in which order the node should appear within the context
*
* @return DataResponse<Http::STATUS_OK, TablesContext, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND, array{message: string}, array{}>
*
* 200: Node added successfully
* 403: No permissions
* 404: Not found
*
* @NoAdminRequired
* @CanManageNode
*/
public function addNode(int $contextId, int $nodeId, int $nodeType, int $permissions, ?int $order = null): DataResponse {
try {
$rel = $this->contextService->addNodeToContextById($contextId, $nodeId, $nodeType, $permissions, $this->userId);
$this->contextService->addNodeRelToPage($rel, $order);
$context = $this->contextService->findById($rel->getContextId(), $this->userId);
return new DataResponse($context->jsonSerialize());
} catch (NotFoundError $e) {
return $this->handleNotFoundError($e);
} catch (DoesNotExistException $e) {
return $this->handleNotFoundError(new NotFoundError($e->getMessage(), $e->getCode(), $e));
} catch (MultipleObjectsReturnedException|Exception|InternalError $e) {
return $this->handleError($e);
}
}

/**
* [api v2] Remove a node from a Context
*
* @param int $contextId ID of the context
* @param int $nodeRelId ID of the node-in-context relation
*
* @return DataResponse<Http::STATUS_OK, TablesContext, array{}>|DataResponse<Http::STATUS_INTERNAL_SERVER_ERROR|Http::STATUS_NOT_FOUND|Http::STATUS_BAD_REQUEST, array{message: string}, array{}>
*
* 200: Node removed successfully
* 400: Invalid request
* 403: No permissions
* 404: Not found
*
* @NoAdminRequired
* @CanManageContext
*/
public function removeNode(int $contextId, int $nodeRelId): DataResponse {
// we could do without the contextId, however it is used by the Permission Middleware
// and also results in a more consistent endpoint url
try {
$context = $this->contextService->findById($contextId, $this->userId);
if (!isset($context->getNodes()[$nodeRelId])) {
return $this->handleBadRequestError(new BadRequestError('Node Relation ID not found in given Context'));
}
$nodeRelation = $this->contextService->removeNodeFromContextById($nodeRelId);
$this->contextService->removeNodeRelFromAllPages($nodeRelation);
$context = $this->contextService->findById($contextId, $this->userId);
return new DataResponse($context->jsonSerialize());
} catch (NotFoundError $e) {
return $this->handleNotFoundError($e);
} catch (DoesNotExistException $e) {
return $this->handleNotFoundError(new NotFoundError($e->getMessage(), $e->getCode(), $e));
} catch (MultipleObjectsReturnedException|Exception|InternalError $e) {
return $this->handleError($e);
}
}

/**
* [api v2] Update the order on a page of a context
*
Expand Down
Loading
Loading