Skip to content

Commit

Permalink
FRW-8560 Extended DDE configuration (#10957)
Browse files Browse the repository at this point in the history
FRW-8567 fixed DELETE method response message & added configuration for abstract product URLs.
  • Loading branch information
dimitriyTsemma authored May 30, 2024
1 parent 3db92f3 commit 94c666f
Showing 1 changed file with 20 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ class DynamicEntityDeleter implements DynamicEntityDeleterInterface
*/
protected const PLACEHOLDER_ALIAS_NAME = '%aliasName%';

/**
* @var string
*/
protected const PLACEHOLDER_ERROR_PATH = '%errorPath%';

/**
* @var string
*/
Expand Down Expand Up @@ -91,13 +96,23 @@ public function deleteEntityCollection(
$dynamicEntityConfigurationTransfer = $this->getDynamicEntityConfigurationTransfer($dynamicEntityCriteriaTransfer);

if ($dynamicEntityConfigurationTransfer->getDynamicEntityDefinitionOrFail()->getIsDeletable() !== true) {
return $this->createErrorResponse($dynamicEntityCriteriaTransfer, static::ERROR_MESSAGE_METHOD_NOT_ALLOWED);
return $this->createErrorResponse(
[
static::PLACEHOLDER_ALIAS_NAME => $dynamicEntityCriteriaTransfer->getDynamicEntityConditionsOrFail()->getTableAliasOrFail(),
],
static::ERROR_MESSAGE_METHOD_NOT_ALLOWED,
);
}

$dynamicEntityCollectionTransfer = $this->dynamicEntityReader->getEntityCollection($dynamicEntityCriteriaTransfer);

if ($dynamicEntityCollectionTransfer->getDynamicEntities()->count() === 0) {
return $this->createErrorResponse($dynamicEntityCriteriaTransfer, static::ERROR_MESSAGE_ENTITY_NOT_EXIST);
return $this->createErrorResponse(
[
static::PLACEHOLDER_ERROR_PATH => $dynamicEntityCriteriaTransfer->getDynamicEntityConditionsOrFail()->getTableAliasOrFail(),
],
static::ERROR_MESSAGE_ENTITY_NOT_EXIST,
);
}

if ($dynamicEntityCollectionTransfer->getErrors()->count() !== 0) {
Expand All @@ -111,20 +126,18 @@ public function deleteEntityCollection(
}

/**
* @param \Generated\Shared\Transfer\DynamicEntityCriteriaTransfer $dynamicEntityCriteriaTransfer
* @param array<string, string> $parameters
* @param string $errorMessage
*
* @return \Generated\Shared\Transfer\DynamicEntityCollectionResponseTransfer
*/
protected function createErrorResponse(
DynamicEntityCriteriaTransfer $dynamicEntityCriteriaTransfer,
array $parameters,
string $errorMessage
): DynamicEntityCollectionResponseTransfer {
$errorTransfer = (new ErrorTransfer())
->setMessage($errorMessage)
->setParameters([
static::PLACEHOLDER_ALIAS_NAME => $dynamicEntityCriteriaTransfer->getDynamicEntityConditionsOrFail()->getTableAliasOrFail(),
]);
->setParameters($parameters);

return (new DynamicEntityCollectionResponseTransfer())
->addError($errorTransfer);
Expand Down

0 comments on commit 94c666f

Please sign in to comment.