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

Added translation configuration #64

Merged
merged 1 commit into from
Aug 26, 2023
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
17 changes: 17 additions & 0 deletions src/bundle/DependencyInjection/IbexaRestExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,30 @@ public function prepend(ContainerBuilder $container)
}

$this->prependRouterConfiguration($container);
$this->prependJMSTranslation($container);
}

private function prependRouterConfiguration(ContainerBuilder $container)
{
$config = ['router' => ['default_router' => ['non_siteaccess_aware_routes' => ['ibexa.rest.']]]];
$container->prependExtensionConfig('ibexa', $config);
}

private function prependJMSTranslation(ContainerBuilder $container): void
{
$container->prependExtensionConfig('jms_translation', [
'configs' => [
'ibexa_rest' => [
'dirs' => [
__DIR__ . '/../../',
],
'excluded_dirs' => ['Behat', 'Tests', 'node_modules', 'Features'],
'output_dir' => __DIR__ . '/../Resources/translations/',
'output_format' => 'xliff',
],
],
]);
}
}

class_alias(IbexaRestExtension::class, 'EzSystems\EzPlatformRestBundle\DependencyInjection\EzPlatformRestExtension');
81 changes: 81 additions & 0 deletions src/bundle/Resources/translations/repository_exceptions.en.xliff
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
<?xml version="1.0" encoding="utf-8"?>
<xliff xmlns="urn:oasis:names:tc:xliff:document:1.2" xmlns:jms="urn:jms:translation" version="1.2">
<file source-language="en" target-language="en" datatype="plaintext" original="not.available">
<header>
<tool tool-id="JMSTranslationBundle" tool-name="JMSTranslationBundle" tool-version="1.1.0-DEV"/>
<note>The source node in most cases contains the sample message as written by the developer. If it looks like a dot-delimitted string such as "form.label.firstname", then the developer has not provided a default message.</note>
</header>
<body>
<trans-unit id="6b5380565700746eb00dfa6b096b5db86d590589" resname="Cannot publish an empty Content Type draft">
<source>Cannot publish an empty Content Type draft</source>
<target state="new">Cannot publish an empty Content Type draft</target>
<note>key: Cannot publish an empty Content Type draft</note>
</trans-unit>
<trans-unit id="05517432cfd855bfa4417139564c188c02654b4c" resname="Cannot unlink the Content Type from its only remaining group">
<source>Cannot unlink the Content Type from its only remaining group</source>
<target state="new">Cannot unlink the Content Type from its only remaining group</target>
<note>key: Cannot unlink the Content Type from its only remaining group</note>
</trans-unit>
<trans-unit id="0b525944af0bdcb0dd04bcaa4a027212bffc9738" resname="Current version already has DRAFT status">
<source>Current version already has DRAFT status</source>
<target state="new">Current version already has DRAFT status</target>
<note>key: Current version already has DRAFT status</note>
</trans-unit>
<trans-unit id="3488686cd9f81f72d18993fefc0d4de7d17bc52b" resname="Only empty Content Type groups can be deleted">
<source>Only empty Content Type groups can be deleted</source>
<target state="new">Only empty Content Type groups can be deleted</target>
<note>key: Only empty Content Type groups can be deleted</note>
</trans-unit>
<trans-unit id="309f294f925bf5343de6ca4507a303bbc762090f" resname="Only versions with DRAFT status can be published">
<source>Only versions with DRAFT status can be published</source>
<target state="new">Only versions with DRAFT status can be published</target>
<note>key: Only versions with DRAFT status can be published</note>
</trans-unit>
<trans-unit id="9698733c46daf6173c56ac6b9cdcb05cef60fbd6" resname="Only versions with DRAFT status can be updated">
<source>Only versions with DRAFT status can be updated</source>
<target state="new">Only versions with DRAFT status can be updated</target>
<note>key: Only versions with DRAFT status can be updated</note>
</trans-unit>
<trans-unit id="c13178e601c4bf79ad9ef57efe468ed438a9b167" resname="Relation is not of type COMMON">
<source>Relation is not of type COMMON</source>
<target state="new">Relation is not of type COMMON</target>
<note>key: Relation is not of type COMMON</note>
</trans-unit>
<trans-unit id="8da63ffae0f9707c46ca02d66e9074e7f9f538d6" resname="Relation of type COMMON can only be added to drafts">
<source>Relation of type COMMON can only be added to drafts</source>
<target state="new">Relation of type COMMON can only be added to drafts</target>
<note>key: Relation of type COMMON can only be added to drafts</note>
</trans-unit>
<trans-unit id="388dae35f493b4e06e6458455f4837b1691fd72b" resname="Relation of type COMMON can only be removed from drafts">
<source>Relation of type COMMON can only be removed from drafts</source>
<target state="new">Relation of type COMMON can only be removed from drafts</target>
<note>key: Relation of type COMMON can only be removed from drafts</note>
</trans-unit>
<trans-unit id="fe5e61a2dbe9daf82bf81a65e725bc070e17cc03" resname="Relation of type COMMON to the selected destination content ID already exists">
<source>Relation of type COMMON to the selected destination content ID already exists</source>
<target state="new">Relation of type COMMON to the selected destination content ID already exists</target>
<note>key: Relation of type COMMON to the selected destination content ID already exists</note>
</trans-unit>
<trans-unit id="fd9dfe52da409af010a267fa2ad0a70d077b73c4" resname="The Content Type is already linked to the provided group">
<source>The Content Type is already linked to the provided group</source>
<target state="new">The Content Type is already linked to the provided group</target>
<note>key: The Content Type is already linked to the provided group</note>
</trans-unit>
<trans-unit id="d71c63955373cbd73161528026feb878e5e042b8" resname="Translation can be deleted from a DRAFT version only">
<source>Translation can be deleted from a DRAFT version only</source>
<target state="new">Translation can be deleted from a DRAFT version only</target>
<note>key: Translation can be deleted from a DRAFT version only</note>
</trans-unit>
<trans-unit id="28a8101ba74e406141eefc3a89ce0d743659707d" resname="Versions with PUBLISHED status cannot be deleted">
<source>Versions with PUBLISHED status cannot be deleted</source>
<target state="new">Versions with PUBLISHED status cannot be deleted</target>
<note>key: Versions with PUBLISHED status cannot be deleted</note>
</trans-unit>
<trans-unit id="9307ee9a550b5c318fbbd6f5750e95d1de1d3483" resname="non_verbose_error">
<source>An error has occurred. Please try again later or contact your Administrator.</source>
<target state="new">An error has occurred. Please try again later or contact your Administrator.</target>
<note>key: non_verbose_error</note>
</trans-unit>
</body>
</file>
</xliff>
3 changes: 2 additions & 1 deletion src/lib/Server/Controller/Content.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use Ibexa\Rest\Server\Values\RestContentCreateStruct;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\HttpKernelInterface;

Expand Down Expand Up @@ -710,7 +711,7 @@ public function createRelation($contentId, $versionNumber, Request $request)
try {
$destinationContentInfo = $this->repository->getContentService()->loadContentInfo($destinationContentId);
} catch (NotFoundException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

$existingRelations = $this->repository->getContentService()->loadRelations($versionInfo);
Expand Down
21 changes: 11 additions & 10 deletions src/lib/Server/Controller/ContentType.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Ibexa\Rest\Server\Exceptions\BadRequestException;
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -68,7 +69,7 @@ public function createContentTypeGroup(Request $request)
]
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down Expand Up @@ -98,7 +99,7 @@ public function updateContentTypeGroup($contentTypeGroupId, Request $request)

return $this->contentTypeService->loadContentTypeGroup($contentTypeGroupId, Language::ALL);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down Expand Up @@ -304,7 +305,7 @@ public function createContentType($contentTypeGroupId, Request $request)
[$contentTypeGroup]
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (ContentTypeValidationException $e) {
throw new BadRequestException($e->getMessage());
} catch (ContentTypeFieldDefinitionValidationException $e) {
Expand Down Expand Up @@ -378,7 +379,7 @@ public function createContentTypeDraft($contentTypeId, Request $request)
$contentType
);
} catch (BadStateException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

$contentTypeUpdateStruct = $this->inputDispatcher->parse(
Expand All @@ -396,7 +397,7 @@ public function createContentTypeDraft($contentTypeId, Request $request)
$contentTypeUpdateStruct
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\CreatedContentType(
Expand Down Expand Up @@ -455,7 +456,7 @@ public function updateContentTypeDraft($contentTypeId, Request $request)
$contentTypeUpdateStruct
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\RestContentType(
Expand Down Expand Up @@ -494,11 +495,11 @@ public function addContentTypeDraftFieldDefinition($contentTypeId, Request $requ
$fieldDefinitionCreate
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (ContentTypeFieldDefinitionValidationException $e) {
throw new BadRequestException($e->getMessage());
} catch (BadStateException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

$updatedDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
Expand Down Expand Up @@ -678,7 +679,7 @@ public function updateContentTypeDraftFieldDefinition($contentTypeId, $fieldDefi
$fieldDefinitionUpdate
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

$updatedDraft = $this->contentTypeService->loadContentTypeDraft($contentTypeId);
Expand Down Expand Up @@ -768,7 +769,7 @@ public function deleteContentType($contentTypeId)
try {
$this->contentTypeService->deleteContentType($contentType);
} catch (BadStateException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\NoContent();
Expand Down
3 changes: 2 additions & 1 deletion src/lib/Server/Controller/Location.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Ibexa\Rest\Server\Exceptions\BadRequestException;
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -125,7 +126,7 @@ public function createLocation($contentId, Request $request)
try {
$createdLocation = $this->locationService->createLocation($contentInfo, $locationCreateStruct);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\CreatedLocation(['restLocation' => new Values\RestLocation($createdLocation, 0)]);
Expand Down
14 changes: 9 additions & 5 deletions src/lib/Server/Controller/ObjectState.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Ibexa\Rest\Server\Values;
use Ibexa\Rest\Values\ContentObjectStates;
use Ibexa\Rest\Values\RestObjectState;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -69,7 +70,7 @@ public function createObjectStateGroup(Request $request)
)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */$e->getMessage());
}

return new Values\CreatedObjectStateGroup(
Expand Down Expand Up @@ -103,7 +104,7 @@ public function createObjectState($objectStateGroupId, Request $request)
)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\CreatedObjectState(
Expand Down Expand Up @@ -230,7 +231,7 @@ public function updateObjectStateGroup($objectStateGroupId, Request $request)

return $updatedStateGroup;
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down Expand Up @@ -260,7 +261,7 @@ public function updateObjectState($objectStateGroupId, $objectStateId, Request $

return new RestObjectState($updatedObjectState, $objectStateGroupId);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down Expand Up @@ -321,7 +322,10 @@ public function setObjectStatesForContent($contentId, Request $request)

foreach ($countByGroups as $groupId => $count) {
if ($count > 1) {
throw new ForbiddenException("Multiple Object states provided for group with ID $groupId");
throw new ForbiddenException(
/** @Ignore */
"Multiple Object states provided for group with ID $groupId"
);
}
}

Expand Down
9 changes: 5 additions & 4 deletions src/lib/Server/Controller/Role.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Exceptions\BadRequestException;
use Ibexa\Rest\Server\Values;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -95,9 +96,9 @@ public function createRole(Request $request)
)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (UnauthorizedException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (LimitationValidationException $e) {
throw new BadRequestException($e->getMessage());
} catch (Exceptions\Parser $e) {
Expand Down Expand Up @@ -139,9 +140,9 @@ public function createRoleDraft($roleId, Request $request)
$this->roleService->loadRole($roleId)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (UnauthorizedException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
} catch (LimitationValidationException $e) {
throw new BadRequestException($e->getMessage());
} catch (Exceptions\Parser $e) {
Expand Down
4 changes: 2 additions & 2 deletions src/lib/Server/Controller/Section.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public function createSection(Request $request)
)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}

return new Values\CreatedSection(
Expand Down Expand Up @@ -135,7 +135,7 @@ public function updateSection($sectionId, Request $request)
$this->mapToUpdateStruct($createStruct)
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/Server/Controller/Trash.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use InvalidArgumentException;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -147,7 +148,7 @@ public function restoreTrashItem($trashItemId, Request $request)
try {
$parentLocation = $this->locationService->loadLocation(array_pop($locationPathParts));
} catch (NotFoundException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand All @@ -159,7 +160,7 @@ public function restoreTrashItem($trashItemId, Request $request)
try {
$this->locationService->loadLocation($trashItem->parentLocationId);
} catch (NotFoundException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down
5 changes: 3 additions & 2 deletions src/lib/Server/Controller/URLAlias.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use Ibexa\Rest\Server\Controller as RestController;
use Ibexa\Rest\Server\Exceptions\ForbiddenException;
use Ibexa\Rest\Server\Values;
use JMS\TranslationBundle\Annotation\Ignore;
use Symfony\Component\HttpFoundation\Request;

/**
Expand Down Expand Up @@ -132,7 +133,7 @@ public function createURLAlias(Request $request)
$urlAliasCreate['alwaysAvailable']
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
} else {
try {
Expand All @@ -144,7 +145,7 @@ public function createURLAlias(Request $request)
$urlAliasCreate['alwaysAvailable']
);
} catch (InvalidArgumentException $e) {
throw new ForbiddenException($e->getMessage());
throw new ForbiddenException(/** @Ignore */ $e->getMessage());
}
}

Expand Down
Loading
Loading