Skip to content

Commit

Permalink
pimcore x support (dachcom-digital#84)
Browse files Browse the repository at this point in the history
* pimcore x support
* disable debug mode in ZoneHostCest
* [tests] use default static route definitions
* Adds header which is send by akamai cdn
* disallow redirect in frontend request by admin, see dachcom-digital#82
* fix data collector
* rebuild i18n and introduce zone builder
* fix phpstan issues and re-adjust some tests
* fix error documents tests
* fix zone error pages test
* introduce routeItems
* remove more logic from zone model, introduce context object and resolver
* improve context detection
* handle exception context right
* fix simple zone resolver
* improve exception handling
  • Loading branch information
solverat authored Nov 8, 2021
1 parent 731e808 commit 8200307
Show file tree
Hide file tree
Showing 162 changed files with 5,268 additions and 5,233 deletions.
49 changes: 23 additions & 26 deletions .github/workflows/codeception.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,16 @@ jobs:
env:
TEST_BUNDLE_NAME: "I18nBundle"
TEST_BUNDLE_INSTALLER_CLASS: "I18nBundle\\Tool\\Install"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests"
TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}"

PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework"
PIMCORE_CODECEPTION_VERSION: "1.0"
PIMCORE_CODECEPTION_VERSION: "2.0"

PIMCORE_ENVIRONMENT: test
APP_ENV: test
PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test"
PIMCORE_TEST_URL: "http://localhost"
PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/tests/_output/var/classes/DataObject"
PIMCORE_CLASS_DIRECTORY: "${{ github.workspace }}/lib/test-bundle/tests/_output/var/classes/DataObject"

SYMFONY_DEPRECATIONS_HELPER: "weak"
PIMCORE_PHP_ERROR_REPORTING: 32767
Expand All @@ -41,31 +41,30 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
php: [7.4]
symfony: [^4.4]
pimcore: [~6.6.0, ~6.7.0, ~6.8.0]
php: [ 8.0 ]
symfony: [ ^5.3 ]
pimcore: [ ~10.1.0, ~10.2.0 ]
include:
- pimcore: ~6.6.0
template_tag: v2.6.0
- pimcore: ~6.7.0
template_tag: v2.7.0
- pimcore: ~6.8.0
template_tag: v2.8.0
- pimcore: ~6.8.0
symfony: ^3.4
php: 7.4
template_tag: v2.8.0
- pimcore: ~10.1.0
template_tag: v10.1.0
- pimcore: ~10.2.0
template_tag: v10.1.4
steps:
- uses: actions/checkout@v2
with:
path: lib/test-bundle

- name: Generate Application Structure
run: |
git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git
mv skeleton/app .
mv skeleton/composer.json .
mv skeleton/bin .
mv skeleton/config .
mv skeleton/public .
mv skeleton/src .
mv skeleton/templates .
mv skeleton/var .
mv skeleton/web .
mv skeleton/src/AppBundle src
rm -r skeleton
- name: Setup Pimcore Codeception Framework
env:
Expand Down Expand Up @@ -106,8 +105,6 @@ jobs:
- name: Setup MySql
run: |
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_file_format=Barracuda;"
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_large_prefix=1;"
mysql -uroot -h127.0.0.1 -proot -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;"
- name: Setup Chromium
Expand All @@ -117,7 +114,7 @@ jobs:
- name: Start Webserver and Chrome
run: |
wget https://get.symfony.com/cli/installer -O - | bash
~/.symfony/bin/symfony server:start --port=8080 --dir=web --force-php-discovery --allow-http --no-tls --daemon
~/.symfony/bin/symfony server:start --port=8080 --dir=public --force-php-discovery --allow-http --no-tls --daemon
- name: Get Composer Cache Directory
id: composer-cache
Expand All @@ -142,7 +139,7 @@ jobs:
- name: Assets Install
run: |
bin/console assets:install web --relative --symlink
bin/console assets:install public --relative --symlink
- name: Tests
run: |
Expand All @@ -154,12 +151,12 @@ jobs:
echo "127.0.0.1 test-domain6.test" | sudo tee -a /etc/hosts
echo "127.0.0.1 test-domain7.test" | sudo tee -a /etc/hosts
bin/console cache:warmup --env=test
vendor/bin/codecept run --env github -c ${{ env.GITHUB_WORKSPACE }}
vendor/bin/codecept run --env github -c ${{ github.workspace }}/lib/test-bundle
- name: Log Output
uses: actions/upload-artifact@v2
if: failure()
with:
name: "Logs (PHP ${{ matrix.php }}, Pimcore ${{ matrix.pimcore }}, Symfony ${{ matrix.symfony }})"
path: tests/_output/
path: ${{ github.workspace }}/lib/test-bundle/tests/_output/
if-no-files-found: ignore
34 changes: 18 additions & 16 deletions .github/workflows/ecs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
env:
TEST_BUNDLE_NAME: "I18nBundle"
TEST_BUNDLE_INSTALLER_CLASS: "I18nBundle\\Tool\\Install"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests"
TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}"

PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework"
PIMCORE_CODECEPTION_VERSION: "1.0"
PIMCORE_CODECEPTION_VERSION: "2.0"

PIMCORE_ENVIRONMENT: test
APP_ENV: test
PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test"
PIMCORE_TEST_URL: "http://localhost"

Expand All @@ -40,24 +40,28 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
php: [7.4]
symfony: [^4.4]
pimcore: [^6.8]
php: [ 8.0 ]
symfony: [ ^5.3 ]
pimcore: [ ~10.1.0 ]
include:
- pimcore: ^6.8
template_tag: v2.8.0

- pimcore: ~10.1.0
template_tag: v10.1.0
steps:
- uses: actions/checkout@v2
with:
path: lib/test-bundle

- name: Generate Application Structure
run: |
git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git
mv skeleton/app .
mv skeleton/composer.json .
mv skeleton/bin .
mv skeleton/config .
mv skeleton/public .
mv skeleton/src .
mv skeleton/templates .
mv skeleton/var .
mv skeleton/web .
mv skeleton/src/AppBundle src
rm -r skeleton
- name: Setup Pimcore Codeception Framework
env:
Expand Down Expand Up @@ -91,8 +95,6 @@ jobs:
- name: Setup MySql
run: |
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_file_format=Barracuda;"
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_large_prefix=1;"
mysql -uroot -h127.0.0.1 -proot -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;"
- name: Get Composer Cache Directory
Expand All @@ -118,10 +120,10 @@ jobs:
- name: Assets Install
run: |
bin/console assets:install web --relative --symlink
bin/console assets:install public --relative --symlink
- name: Easy Coding Standard Check
continue-on-error: true
run: |
bin/console cache:warmup --env=test
vendor/bin/ecs check src/I18nBundle --config easy-coding-standard.yml
vendor/bin/ecs check ${{ github.workspace }}/lib/test-bundle/src/I18nBundle --config ${{ github.workspace }}/lib/test-bundle/ecs.php
33 changes: 18 additions & 15 deletions .github/workflows/php-stan.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ jobs:
env:
TEST_BUNDLE_NAME: "I18nBundle"
TEST_BUNDLE_INSTALLER_CLASS: "I18nBundle\\Tool\\Install"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/tests"
TEST_BUNDLE_TEST_DIR: "${{ github.workspace }}/lib/test-bundle/tests"
TEST_PROJECT_ROOT_DIR: "${{ github.workspace }}"

PIMCORE_CODECEPTION_FRAMEWORK: "${{ github.workspace }}/pimcore-codeception-framework"
PIMCORE_CODECEPTION_VERSION: "1.0"
PIMCORE_CODECEPTION_VERSION: "2.0"

PIMCORE_ENVIRONMENT: test
APP_ENV: test
PIMCORE_TEST_DB_DSN: "mysql://root:root@localhost/dachcom_bundle_test"
PIMCORE_TEST_URL: "http://localhost"

Expand All @@ -40,23 +40,28 @@ jobs:
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
strategy:
matrix:
php: [7.4]
symfony: [^4.4]
pimcore: [^6.8]
php: [ 8.0 ]
symfony: [ ^5.3 ]
pimcore: [ ~10.1.0 ]
include:
- pimcore: ^6.8
template_tag: v2.8.0
- pimcore: ~10.1.0
template_tag: v10.1.0
steps:
- uses: actions/checkout@v2
with:
path: lib/test-bundle

- name: Generate Application Structure
run: |
git clone -b ${{ matrix.template_tag }} --single-branch --depth 1 https://github.com/pimcore/skeleton.git
mv skeleton/app .
mv skeleton/composer.json .
mv skeleton/bin .
mv skeleton/config .
mv skeleton/public .
mv skeleton/src .
mv skeleton/templates .
mv skeleton/var .
mv skeleton/web .
mv skeleton/src/AppBundle src
rm -r skeleton
- name: Setup Pimcore Codeception Framework
env:
Expand Down Expand Up @@ -90,8 +95,6 @@ jobs:
- name: Setup MySql
run: |
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_file_format=Barracuda;"
mysql -uroot -h127.0.0.1 -proot -e "SET GLOBAL innodb_large_prefix=1;"
mysql -uroot -h127.0.0.1 -proot -e "CREATE DATABASE dachcom_bundle_test CHARSET=utf8mb4;"
- name: Get Composer Cache Directory
Expand All @@ -117,9 +120,9 @@ jobs:
- name: Assets Install
run: |
bin/console assets:install web --relative --symlink
bin/console assets:install public --relative --symlink
- name: Php Stan
run: |
bin/console cache:warmup --env=test
vendor/bin/phpstan analyse -c phpstan.neon -a tests/_phpstan-bootstrap.php src -l 2
vendor/bin/phpstan analyse -c${{ github.workspace }}/lib/test-bundle/phpstan.neon -a ${{ github.workspace }}/lib/test-bundle/tests/_phpstan-bootstrap.php ${{ github.workspace }}/lib/test-bundle/src -l 4
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# License
Copyright (C) 2017 DACHCOM.DIGITAL
Copyright (C) 2021 DACHCOM.DIGITAL

This software is available under the GNU General Public License version 3 (GPLv3).

Expand Down
60 changes: 30 additions & 30 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,68 +2,71 @@

[![Software License](https://img.shields.io/badge/license-GPLv3-brightgreen.svg?style=flat-square)](LICENSE.md)
[![Latest Release](https://img.shields.io/packagist/v/dachcom-digital/i18n.svg?style=flat-square)](https://packagist.org/packages/dachcom-digital/i18n)
[![Tests](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-i18n/Codeception?style=flat-square&logo=github&label=codeception)](https://github.com/dachcom-digital/pimcore-i18n/actions?query=workflow%3A%22Codeception%22)
[![PhpStan](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-i18n/PHP%20Stan?style=flat-square&logo=github&label=phpstan%20level%202)](https://github.com/dachcom-digital/pimcore-i18n/actions?query=workflow%3A%22PHP%20Stan%22)
[![Tests](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-i18n/Codeception/master?style=flat-square&logo=github&label=codeception)](https://github.com/dachcom-digital/pimcore-i18n/actions?query=workflow%3ACodeception+branch%3Amaster)
[![PhpStan](https://img.shields.io/github/workflow/status/dachcom-digital/pimcore-i18n/PHP%20Stan/master?style=flat-square&logo=github&label=phpstan%20level%204)](https://github.com/dachcom-digital/pimcore-i18n/actions?query=workflow%3A"PHP+Stan"+branch%3Amaster)

![i18n](https://user-images.githubusercontent.com/700119/27761666-f3ed6746-5e60-11e7-955a-3030453c68ff.jpg)

## Scheme
![i18n scheme](https://user-images.githubusercontent.com/700119/140646548-fcf6433d-1fa0-4323-98e2-9cc49550e5ee.png)

## Introduction
Pimcore already comes with some great features to build internationalized websites. But there are some gaps we have to handle by ourselves: search engine guidelines, geo based redirects and a dynamic link handling for internal documents.
This Bundle helps you mastering this challenges and gives you the freedom to elaborate complex country based localization strategies.
Pimcore already comes with some great features to build internationalized websites.
But there are some gaps we have to handle by ourselves: search engine guidelines, geo based redirects, dynamic link handling for internal documents and of course: full qualified URLs for and in every context.
This bundle helps you to master this challenges and gives you the freedom to elaborate complex URL building and (country) based localization strategies.
**Please read the read the [I18n overview page](./docs/1_I18n.md) before starting!**

### Release Plan

| Release | Supported Pimcore Versions | Supported Symfony Versions | Release Date | Maintained | Branch |
|---------|-----------------------------------|----------------------------|--------------|----------------|------------|
| **3.x** | `6.0` - `6.3`, `6.5` - `6.8` | `3.4`, `^4.4` | 18.07.2019 | Feature Branch | dev-master |
| **2.4** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 24.05.2019 | Bugfix only | 2.4 |
| **4.x** | `10.1` | `5.3` | -- | Feature Branch | master |
| **3.x** | `6.0` - `6.3`, `6.5` - `6.9` | `3.4`, `^4.4` | 18.07.2019 | Unsupported | 3.x |
| **2.4** | `5.4`, `5.5`, `5.6`, `5.7`, `5.8` | `3.4` | 24.05.2019 | Unsupported | 2.4 |

### Installation

```json
"require" : {
"dachcom-digital/i18n" : "~3.2.0"
"dachcom-digital/i18n" : "~4.0.0"
}
```

### Installation via Extension Manager
After you have installed the I18n Bundle via composer, open pimcore backend and go to `Tools` => `Extension`:
- Click the green `+` Button in `Enable / Disable` row
- Click the green `+` Button in `Install/Uninstall` row
- Execute: `$ bin/console pimcore:bundle:enable I18nBundle`
- Execute: `$ bin/console pimcore:bundle:install I18nBundle`

## Upgrading

### Upgrading via Extension Manager
After you have updated the I18n Bundle via composer, open pimcore backend and go to `Tools` => `Extension`:
- Click the green `+` Button in `Update` row

### Upgrading via CommandLine
After you have updated the I18n Bundle via composer:
- Execute: `$ bin/console pimcore:bundle:update I18nBundle`

### Migrate via CommandLine
Does actually the same as the update command and preferred in CI-Workflow:
- Execute: `$ bin/console pimcore:migrations:migrate -b I18nBundle`
- Execute: `$ bin/console doctrine:migrations:migrate --prefix 'I18nBundle\Migrations'`

## Features
- Generate fully qualified URLs in any context with symfony's default router
- Geo redirects (read more about the redirector adapter [here](docs/51_RedirectorAdapter.md))
- Thanks to the hardlink element you can easily create copies of webpages with additional country information without adding and maintaining duplicate content
- Manage [href-lang](docs/25_HrefLang.md) tags
- Domain mapping (`domain.com`) and/or language slug (`/en`) strategies
- [front page mapping](docs/30_FrontPageMapping.md) for hardlink trees

### Before you start
When using this bundle, you should:
- **not** using any router but the default `RouterInterface` object.
- **not** using `pimcore_url` or `$staticRoute->assemble()` but using the default `RouterInterface` instead
- extend your `LinkGeneratorInterface` objects with the `I18nLinkGeneratorInterface` and adjust dem accordingly
- **read** the [How I18nBundle works](./docs/1_I18n.md) section

### Preparation
- If you're using `system` as your `locale_adapter`, which is the default, you need to enable all required locales in pimcore system settings
- Always be sure that every document translation is connected via the [localization tool](https://www.pimcore.org/docs/5.0.0/Multi_Language_i18n/Localize_your_Documents.html).
- If you're using the country detection, you need a valid maxmind geoip [data provider](docs/10_GeoControl.md)
- If you're using the country detection, you need a valid maxmind geo ip [data provider](docs/10_GeoControl.md)

## Further Information
- [Geo IP/Control](docs/10_GeoControl.md): Enable GeoIP Data Provider.
- [Zones](docs/20_Zones.md): Learn more about i18n zones and how to manage them.
- [Zone Definitions](docs/20_Zones.md): Learn more about i18n zone definitions and how to manage them.
- [Custom I18n Context Look-Up](docs/21_CustomI18nContextLookUp.md)] (🔥 New!)
- [Href-Lang](docs/25_HrefLang.md): Find out more about the href-lang tag generator.
- [Language Configuration](docs/26_Languages.md): Configure languages.
- [Country Configuration](docs/27_Countries.md): Configure countries.
- [Static Routes](docs/28_StaticRoutes.md): Configure translatable static routes and implement href-lang tags.
- Dynamic Routing
- [Static Routes](docs/28_StaticRoutes.md): Configure translatable static routes and implement href-lang tags.
- [Symfony Route](docs/29_SymfonyRoutes.md): Configure translatable symfony routes and implement href-lang tags.
- [Front Page Mapping](docs/30_FrontPageMapping.md): Learn how to map a custom front page.
- [Localized Error Documents](docs/40_LocaleErrorDocument.md): Learn how to create localized error documents.
- [Custom Locale Adapter](docs/50_CustomLocaleAdapter.md): Learn how to create a custom locale adapter.
Expand All @@ -74,9 +77,6 @@ Does actually the same as the update command and preferred in CI-Workflow:
- [Canonical Links](docs/80_CanonicalLinks.md): Canonical links in hardlinks.
- [Navigation Caching](docs/110_NavigationCaching.md): Cache your navigation right!

## Why is there no Version 1?
There is already an i18n plugin for pimcore4 which is not public. With Pimcore5 we decided to move this project to a public github repository. You're welcome. :)

## Copyright and License
Copyright: [DACHCOM.DIGITAL](http://dachcom-digital.ch)
For licensing details please visit [LICENSE.md](LICENSE.md)
Expand Down
Loading

0 comments on commit 8200307

Please sign in to comment.