Skip to content

Commit

Permalink
Merge pull request #16 from dachcom-digital/prepare-3.0
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed Aug 30, 2023
2 parents af8c660 + 8a5cab8 commit 681c6d9
Show file tree
Hide file tree
Showing 7 changed files with 75 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Expand Up @@ -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 |

Expand Down
3 changes: 3 additions & 0 deletions UPGRADE.md
Expand Up @@ -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
2 changes: 1 addition & 1 deletion config/pimcore/config.yaml
Expand Up @@ -14,4 +14,4 @@ doctrine:

doctrine_migrations:
migrations_paths:
'JobsBundle\Migrations': '@JobsBundle/Migrations'
'JobsBundle\Migrations': '@JobsBundle/src/Migrations'
15 changes: 10 additions & 5 deletions docs/00_Setup.md
Expand Up @@ -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 |


Expand All @@ -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
Expand Down Expand Up @@ -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.

***

Expand Down
4 changes: 3 additions & 1 deletion phpstan.neon
Expand Up @@ -14,4 +14,6 @@ parameters:
ignoreErrors:
# 3rd parties
- '/.*Spatie\\SchemaOrg\\Graph.*/'
- '/.*League\\OAuth2\\Client.*/'
- '/.*League\\OAuth2\\Client.*/'
- '#Class I18nBundle\\LinkGenerator\\I18nLinkGeneratorInterface not found\.#'
- '#Call to static method buildForEntity\(\) on an unknown class I18nBundle\\Builder\\RouteParameterBuilder\.#'
30 changes: 30 additions & 0 deletions src/Service/LinkGeneratorService.php
Expand Up @@ -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 = [
Expand All @@ -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);
}
Expand Down
27 changes: 27 additions & 0 deletions tests/_etc/config/app/config.yaml
Expand Up @@ -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
Expand Down

0 comments on commit 681c6d9

Please sign in to comment.