Skip to content

Commit

Permalink
Consistency checks
Browse files Browse the repository at this point in the history
  • Loading branch information
mattamon committed Jun 3, 2024
1 parent 055abf9 commit bc4120d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/Dependency/Controller/Element/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,8 @@ public function __construct(
#[Get(
path: self::API_PATH . '/dependencies/{elementType}/{id}',
operationId: 'getDependencies',
description: 'Get paginated dependencies.
Pass dependency mode to get either all elements that depend on the provided element
description: 'Get paginated dependencies.
Pass dependency mode to get either all elements that depend on the provided element
or all dependencies for the provided element.',
summary: 'Get all dependencies for provided element.',
security: self::SECURITY_SCHEME,
Expand Down
8 changes: 6 additions & 2 deletions src/Request/ElementParameters.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Pimcore\ValueObject\Integer\PositiveInteger;
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Constraints\Positive;
use ValueError;

/**
* @internal
Expand Down Expand Up @@ -50,12 +51,15 @@ public function getId(): int
return $this->id;
}


/**
* @throws InvalidElementTypeException|ValueError
*/
private function validate(): void
{
if (!in_array($this->type, ElementTypes::ALLOWED_TYPES)){
if (!in_array($this->type, ElementTypes::ALLOWED_TYPES)) {
throw new InvalidElementTypeException($this->type);
}

new PositiveInteger($this->id);
}
}
3 changes: 2 additions & 1 deletion src/Version/Controller/Element/CleanupController.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public function __construct(
public function cleanupVersions(
string $elementType,
int $id,
#[MapQueryString] VersionCleanupParameters $parameters): JsonResponse
#[MapQueryString] VersionCleanupParameters $parameters
): JsonResponse
{
return $this->jsonResponse(
['ids' => $this->versionService->cleanupVersions(new ElementParameters($elementType, $id), $parameters)]
Expand Down
3 changes: 2 additions & 1 deletion src/Version/Controller/Element/CollectionController.php
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ public function __construct(
public function getVersions(
string $elementType,
int $id,
#[MapQueryString] CollectionParameters $parameters): JsonResponse
#[MapQueryString] CollectionParameters $parameters
): JsonResponse
{
$collection = $this->versionService->getVersions(
new ElementParameters($elementType, $id),
Expand Down

0 comments on commit bc4120d

Please sign in to comment.