diff --git a/README.md b/README.md index cabb7c7..1cb5e61 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ This Bundle allows you to synchronise your job offers with various connectors li | Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch | |---------|----------------------------|----------------------------|--------------|----------------|------------| -| **3.x** | `11.0` | `6.2` | -- | Feature Branch | dev-master | +| **3.x** | `11.0` | `6.2` | 30.08.2023 | Feature Branch | dev-master | | **2.x** | `10.5`, `10.6` | `5.4` | 14.10.2021 | Bugfixes | 2.x | | **1.x** | `6.0` - `6.9` | `3.4`, `^4.4` | 27.04.2020 | Unsupported | 1.x | diff --git a/UPGRADE.md b/UPGRADE.md index ab0487f..a0240a6 100644 --- a/UPGRADE.md +++ b/UPGRADE.md @@ -5,6 +5,9 @@ ### Global Changes - Recommended folder structure by symfony adopted +### New Features +- i18n link generator support + *** JobsBundle 2.x Upgrade Notes: https://github.com/dachcom-digital/pimcore-jobs/blob/2.x/UPGRADE.md diff --git a/config/pimcore/config.yaml b/config/pimcore/config.yaml index 0ceb8b8..7bee26c 100644 --- a/config/pimcore/config.yaml +++ b/config/pimcore/config.yaml @@ -14,4 +14,4 @@ doctrine: doctrine_migrations: migrations_paths: - 'JobsBundle\Migrations': '@JobsBundle/Migrations' + 'JobsBundle\Migrations': '@JobsBundle/src/Migrations' diff --git a/docs/00_Setup.md b/docs/00_Setup.md index 2fb6376..f1fbc60 100644 --- a/docs/00_Setup.md +++ b/docs/00_Setup.md @@ -50,9 +50,9 @@ Click on the `Add` button to create your first Context Definition: ![image](https://user-images.githubusercontent.com/700119/79229692-c0385200-7e63-11ea-90d3-c156443a6f6a.png) -| Name | Description -|------|------------| -| `Host` | Define your host. This is required to generate absolute links | +| Name | Description | +|----------|------------------------------------------------------------------------| +| `Host` | Define your host. This is required to generate absolute links | | `Locale` | Set a locale. The Job Object should get transformed within this locale | @@ -62,6 +62,11 @@ You can add as many Context Definitions as you want. However, please note that s Your Job Object needs a valid Link Generator. If you already have created a Link Generator make sure that you're respecting the host value. +> [!NOTE] +> If you're using the I18n Bundle, you don't have to build such a complex link generator. +> JobsBundle will automatically send all required data to the link generator instead. + + A Link Generator could look like this: ```php @@ -106,8 +111,8 @@ class ObjectLinkGenerator implements LinkGeneratorInterface ``` ### VI. The Connector Configuration -This is the final step: Setup your Connectors. Each connectors has its own configuration and strategies. -Let's checkout the [Connector](./10_Connectors.md) Guide to learn how to use and install them. +This is the final step: Set up your Connectors. Each connector has its own configuration and strategies. +Lets checkout the [Connector](./10_Connectors.md) Guide to learn how to use and install them. *** diff --git a/phpstan.neon b/phpstan.neon index b24610d..572eafa 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -14,4 +14,6 @@ parameters: ignoreErrors: # 3rd parties - '/.*Spatie\\SchemaOrg\\Graph.*/' - - '/.*League\\OAuth2\\Client.*/' \ No newline at end of file + - '/.*League\\OAuth2\\Client.*/' + - '#Class I18nBundle\\LinkGenerator\\I18nLinkGeneratorInterface not found\.#' + - '#Call to static method buildForEntity\(\) on an unknown class I18nBundle\\Builder\\RouteParameterBuilder\.#' \ No newline at end of file diff --git a/src/Service/LinkGeneratorService.php b/src/Service/LinkGeneratorService.php index 375ae37..2b767bf 100644 --- a/src/Service/LinkGeneratorService.php +++ b/src/Service/LinkGeneratorService.php @@ -2,12 +2,20 @@ namespace JobsBundle\Service; +use I18nBundle\Builder\RouteParameterBuilder; +use I18nBundle\LinkGenerator\I18nLinkGeneratorInterface; use JobsBundle\Model\ConnectorContextItemInterface; use Pimcore\Model\DataObject\ClassDefinition\LinkGeneratorInterface; use Pimcore\Model\DataObject\Concrete; +use Pimcore\Model\Site; +use Symfony\Component\Routing\Generator\UrlGeneratorInterface; class LinkGeneratorService implements LinkGeneratorServiceInterface { + public function __construct(protected UrlGeneratorInterface $urlGenerator) + { + } + public function generate(Concrete $object, ConnectorContextItemInterface $contextItem): ?string { $linkGeneratorContext = [ @@ -17,6 +25,28 @@ public function generate(Concrete $object, ConnectorContextItemInterface $contex $dataUrl = null; $linkGenerator = $object->getClass()->getLinkGenerator(); + + // support for i18n + if ($linkGenerator instanceof I18nLinkGeneratorInterface) { + + $definition = $contextItem->getContextDefinition(); + + $context = []; + $routeParameter = [ + '_locale' => $definition->getLocale(), + ]; + + $pimcoreSite = Site::getByDomain(parse_url($definition->getHost(), PHP_URL_HOST)); + + if ($pimcoreSite instanceof Site) { + $context['site'] = $pimcoreSite; + } + + $routeItemParameters = RouteParameterBuilder::buildForEntity($object, $routeParameter, $context); + + return $this->urlGenerator->generate('', $routeItemParameters, UrlGeneratorInterface::ABSOLUTE_URL); + } + if ($linkGenerator instanceof LinkGeneratorInterface) { $dataUrl = $linkGenerator->generate($object, $linkGeneratorContext); } diff --git a/tests/_etc/config/app/config.yaml b/tests/_etc/config/app/config.yaml index 53f2720..b278a5d 100755 --- a/tests/_etc/config/app/config.yaml +++ b/tests/_etc/config/app/config.yaml @@ -18,6 +18,33 @@ doctrine: enum: string bit: boolean +pimcore: + config_location: + image_thumbnails: + write_target: + type: 'settings-store' + video_thumbnails: + write_target: + type: 'settings-store' + document_types: + write_target: + type: 'settings-store' + predefined_properties: + write_target: + type: 'settings-store' + predefined_asset_metadata: + write_target: + type: 'settings-store' + perspectives: + write_target: + type: 'settings-store' + custom_views: + write_target: + type: 'settings-store' + object_custom_layouts: + write_target: + type: 'settings-store' + pimcore_admin: admin_csp_header: enabled: false