From 6681cb640bbdff2d7a0b8827b54268c981ade7e0 Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Thu, 18 Jul 2019 09:12:12 +0200 Subject: [PATCH] Pimcore 6 Compatibility (#30) * adjust tests for P6 * adjust tests for P6 * adjust tests for P6 * adjust tests for P6 * fix error page and default language * fix travis --- .travis.yml | 59 ++---- README.md | 7 +- composer.json | 6 +- phpstan.neon | 6 +- .../Frontend/ResponseExceptionListener.php | 14 +- tests/_etc/bundle_configuration | 2 +- tests/_etc/config/bundle/system.template.php | 172 ------------------ tests/_etc/config/bundle/system.template.yml | 115 ++++++++++++ tests/_etc/travis/install | 4 +- 9 files changed, 147 insertions(+), 238 deletions(-) delete mode 100755 tests/_etc/config/bundle/system.template.php create mode 100755 tests/_etc/config/bundle/system.template.yml diff --git a/.travis.yml b/.travis.yml index b7dfc1a..7de8a98 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,73 +20,40 @@ env: - PIMCORE_TEST_DB_DSN="mysql://root@localhost/dachcom_bundle_test" - SYMFONY_DEPRECATIONS_HELPER=weak - DACHCOM_TEST_SECTION=codeception + - SYMFONY_VERSION=^4.0 matrix: include: - - name: "PHPStan Static Analysis (Pimcore 5.8.x, PHP 7.3)" + - name: "PHPStan Static Analysis (Pimcore 6.0.x, Symfony ^4.0, PHP 7.3)" sudo: required php: 7.3 env: - - PIMCORE_SKELETON_BRANCH="tags/v1.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" - DACHCOM_TEST_SECTION=phpstan - - name: "PHP ECS (Pimcore 5.8.x, PHP 7.3)" + - name: "PHP ECS (Pimcore 6.0.x, Symfony ^4.0, PHP 7.3)" sudo: required php: 7.3 env: - - PIMCORE_SKELETON_BRANCH="tags/v1.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" - DACHCOM_TEST_SECTION=ecs - - name: "Codeception Tests (Pimcore 5.4.x, PHP 7.2)" + - name: "Codeception Tests (Pimcore 6.0.x, Symfony ^4.0, PHP 7.2)" sudo: required php: 7.2 env: - - PIMCORE_SKELETON_BRANCH="tags/v1.0.4" - - name: "Codeception Tests (Pimcore 5.4.x, PHP 7.3)" + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" + - name: "Codeception Tests (Pimcore 6.0.x, Symfony ^4.0, PHP 7.3)" sudo: required php: 7.3 env: - - PIMCORE_SKELETON_BRANCH="tags/v1.0.4" - - name: "Codeception Tests (Pimcore 5.5.x, PHP 7.2)" - sudo: required - php: 7.2 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.0.5" - - name: "Codeception Tests (Pimcore 5.5.x, PHP 7.3)" - sudo: required - php: 7.3 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.0.5" - - name: "Codeception Tests (Pimcore 5.6.x, PHP 7.2)" - sudo: required - php: 7.2 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.1.0" - - name: "Codeception Tests (Pimcore 5.6.x, PHP 7.3)" - sudo: required - php: 7.3 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.1.0" - - name: "Codeception Tests (Pimcore 5.7.x, PHP 7.2)" - sudo: required - php: 7.2 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.2.0" - - name: "Codeception Tests (Pimcore 5.7.x, PHP 7.3)" - sudo: required - php: 7.3 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.2.0" - - name: "Codeception Tests (Pimcore 5.8.x, PHP 7.2)" - sudo: required - php: 7.2 - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.3.0" - - name: "Codeception Tests (Pimcore 5.8.x, PHP 7.3)" + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" + - name: "Codeception Tests (Pimcore 6.0.x, Symfony ^3.4, PHP 7.3)" sudo: required php: 7.3 env: - - PIMCORE_SKELETON_BRANCH="tags/v1.3.0" + - SYMFONY_VERSION=^3.4 + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" allow_failures: - env: - - PIMCORE_SKELETON_BRANCH="tags/v1.3.0" + - PIMCORE_SKELETON_BRANCH="tags/v2.0.0" - DACHCOM_TEST_SECTION=ecs fast_finish: true diff --git a/README.md b/README.md index 607f534..c2a691c 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# Pimcore 5 - i18n Manager +# Pimcore - i18n Manager [![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) @@ -7,9 +7,6 @@ ![i18n](https://user-images.githubusercontent.com/700119/27761666-f3ed6746-5e60-11e7-955a-3030453c68ff.jpg) -## Requirements -* Pimcore >= 5.4.0 - ## 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. @@ -25,7 +22,7 @@ This Bundle helps you mastering this challenges and gives you the freedom to ela ```json "require" : { - "dachcom-digital/i18n" : "~2.4.0" + "dachcom-digital/i18n" : "~3.0.0" } ``` diff --git a/composer.json b/composer.json index 7fd8582..0e49df5 100755 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "dachcom-digital/i18n", "type": "pimcore-bundle", "license": "GPL-3.0-or-later", - "description": "Pimcore 5.x I18n Manager.", + "description": "Pimcore I18n Manager.", "keywords": ["pimcore", "i18n", "localization", "internationalization"], "homepage": "https://github.com/dachcom-digital/pimcore-i18n", "authors": [ @@ -28,10 +28,10 @@ } }, "require": { - "pimcore/core-version": "^5.4.0" + "pimcore/pimcore": "^6.0.0" }, "require-dev": { - "codeception/codeception": "~2.3.0", + "codeception/codeception": "~2.4.0", "phpstan/phpstan": "^0.11.1", "phpstan/phpstan-symfony": "^0.11.0", "symplify/easy-coding-standard": "^5.4" diff --git a/phpstan.neon b/phpstan.neon index b108445..8e4e4c4 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -2,12 +2,12 @@ includes: - ../../vendor/phpstan/phpstan-symfony/extension.neon parameters: reportUnmatchedIgnoredErrors: false - autoload_files: - - %currentWorkingDirectory%/vendor/pimcore/pimcore/stubs/compatibility-v4.php symfony: - container_xml_path: var/cache/dev/appDevDebugProjectContainer.xml + container_xml_path: var/cache/dev/appAppKernelDevDebugContainer.xml ignoreErrors: # There is no global constants definition file we could include, ignore it: - '#Constant PIMCORE_[A-Z\\_]+ not found\.#' + # Symfony DI (remove this line after symfony 4 support only): + - '#Method Symfony\\Contracts\\EventDispatcher\\EventDispatcherInterface::dispatch\(\) invoked with 2 parameters, 1 required\.#' # Symfony DI (remove this line with symfony 4.2): - '#Call to an undefined method Symfony\\Component\\Config\\Definition\\Builder\\NodeDefinition::children\(\)\.#' diff --git a/src/I18nBundle/EventListener/Frontend/ResponseExceptionListener.php b/src/I18nBundle/EventListener/Frontend/ResponseExceptionListener.php index 4a02201..e09f441 100644 --- a/src/I18nBundle/EventListener/Frontend/ResponseExceptionListener.php +++ b/src/I18nBundle/EventListener/Frontend/ResponseExceptionListener.php @@ -259,15 +259,17 @@ private function setRuntime(Request $request, Document $document, $newDocumentLo DataObject\AbstractObject::setGetInheritedValues(true); DataObject\Localizedfield::setGetFallbackValues(true); - $request->setLocale($newDocumentLocale); - $request->setDefaultLocale($newDocumentLocale); - $request->attributes->set('_locale', $newDocumentLocale); - $document->setProperty('language', 'string', $newDocumentLocale); + $saveLocale = is_null($newDocumentLocale) ? 'en' : $newDocumentLocale; + + $request->setLocale($saveLocale); + $request->setDefaultLocale($saveLocale); + $request->attributes->set('_locale', $saveLocale); + $document->setProperty('language', 'string', $saveLocale); //fix i18n language / country context. - Cache\Runtime::set('i18n.locale', $newDocumentLocale); + Cache\Runtime::set('i18n.locale', $saveLocale); - $docLang = explode('_', $newDocumentLocale); + $docLang = explode('_', $saveLocale); Cache\Runtime::set('i18n.languageIso', strtolower($docLang[0])); $countryIso = Definitions::INTERNATIONAL_COUNTRY_NAMESPACE; diff --git a/tests/_etc/bundle_configuration b/tests/_etc/bundle_configuration index aa66a2e..c34f4e4 100755 --- a/tests/_etc/bundle_configuration +++ b/tests/_etc/bundle_configuration @@ -12,7 +12,7 @@ export DACHCOM_BUNDLE_INSTALLER_CLASS='I18nBundle\Tool\Install' declare -A DACHCOM_INSTALL_CONFIG_FILES=( # system files ["$DACHCOM_BUNDLE_HOME/_etc/config/bundle/extensions.template.php"]="var/config/extensions.php" - ["$DACHCOM_BUNDLE_HOME/_etc/config/bundle/system.template.php"]="var/config/system.php" + ["$DACHCOM_BUNDLE_HOME/_etc/config/bundle/system.template.yml"]="var/config/system.yml" ["$DACHCOM_BUNDLE_HOME/_etc/config/bundle/appKernel"]="app/AppKernel.php" # template files ["$DACHCOM_BUNDLE_HOME/_etc/config/bundle/template/controller/DefaultController"]="src/AppBundle/Controller/DefaultController.php" diff --git a/tests/_etc/config/bundle/system.template.php b/tests/_etc/config/bundle/system.template.php deleted file mode 100755 index 4db7979..0000000 --- a/tests/_etc/config/bundle/system.template.php +++ /dev/null @@ -1,172 +0,0 @@ - [ - "timezone" => "Europe/Berlin", - "path_variable" => "", - "domain" => "localhost", - "redirect_to_maindomain" => false, - "language" => "en", - "validLanguages" => "en,de,fr,it,de_DE,en_US,de_CH", - "fallbackLanguages" => [ - "en" => "", - "de" => "", - "fr" => "", - "it" => "", - "de_DE" => "de", - "de_CH" => "de", - "en_US" => "en", - ], - "defaultLanguage" => "en", - "loginscreencustomimage" => "", - "disableusagestatistics" => true, - "debug" => false, - "debug_ip" => "", - "http_auth" => [ - "username" => "", - "password" => "" - ], - "debug_admin_translations" => false, - "devmode" => false, - "instanceIdentifier" => "", - "show_cookie_notice" => false - ], - "database" => [ - "adapter" => "Pdo_Mysql", - "params" => [ - "host" => "localhost", - "username" => "root", - "password" => "", - "dbname" => "dachcom_bundle_test", - "port" => "3306" - ] - ], - "documents" => [ - "versions" => [ - "days" => null, - "steps" => 10 - ], - "default_controller" => "Default", - "default_action" => "default", - "error_pages" => [ - "default" => "/error" - ], - "createredirectwhenmoved" => false, - "allowtrailingslash" => "no", - "generatepreview" => true - ], - "objects" => [ - "versions" => [ - "days" => null, - "steps" => 10 - ] - ], - "assets" => [ - "versions" => [ - "days" => null, - "steps" => 10 - ], - "icc_rgb_profile" => "", - "icc_cmyk_profile" => "", - "hide_edit_image" => false, - "disable_tree_preview" => false - ], - "services" => [ - "google" => [ - "client_id" => "", - "email" => "", - "simpleapikey" => "", - "browserapikey" => "" - ] - ], - "cache" => [ - "enabled" => false, - "lifetime" => null, - "excludePatterns" => "", - "excludeCookie" => "" - ], - "outputfilters" => [ - "less" => false, - "lesscpath" => "" - ], - "webservice" => [ - "enabled" => true - ], - "httpclient" => [ - "adapter" => "Zend_Http_Client_Adapter_Socket", - "proxy_host" => "", - "proxy_port" => "", - "proxy_user" => "", - "proxy_pass" => "" - ], - "email" => [ - "sender" => [ - "name" => "pimcore", - "email" => "pimcore@example.com" - ], - "return" => [ - "name" => "pimcore", - "email" => "pimcore@example.com" - ], - "method" => "mail", - "smtp" => [ - "host" => "", - "port" => "", - "ssl" => null, - "name" => "", - "auth" => [ - "method" => "login", - "username" => "", - "password" => "" - ] - ], - "debug" => [ - "emailaddresses" => "" - ], - "bounce" => [ - "type" => "", - "maildir" => "", - "mbox" => "", - "imap" => [ - "host" => "", - "port" => "", - "username" => "", - "password" => "", - "ssl" => false - ] - ] - ], - "newsletter" => [ - "sender" => [ - "name" => "", - "email" => "" - ], - "return" => [ - "name" => "", - "email" => "" - ], - "method" => null, - "smtp" => [ - "host" => "", - "port" => "", - "ssl" => "ssl", - "name" => "", - "auth" => [ - "method" => null, - "username" => "", - "password" => null - ] - ], - "debug" => null, - "usespecific" => true - ], - "applicationlog" => [ - "mail_notification" => [ - "send_log_summary" => false, - "filter_priority" => null, - "mail_receiver" => "" - ], - "archive_treshold" => "30", - "archive_alternative_database" => "" - ] -]; diff --git a/tests/_etc/config/bundle/system.template.yml b/tests/_etc/config/bundle/system.template.yml new file mode 100755 index 0000000..dd707f5 --- /dev/null +++ b/tests/_etc/config/bundle/system.template.yml @@ -0,0 +1,115 @@ +pimcore: + general: + timezone: Europe/Berlin + language: en + valid_languages: 'en,de,fr,it,de_DE,en_US,de_CH' + path_variable: '' + domain: 'localhost' + redirect_to_maindomain: false + fallback_languages: + en: '' + de: '' + fr: '' + it: '' + de_DE: 'de' + de_CH: 'de' + en_US: 'en' + default_language: en + disable_usage_statistics: true + debug_admin_translations: false + instance_identifier: '' + show_cookie_notice: false + documents: + versions: + steps: 10 + days: null + error_pages: + default: /error + create_redirect_when_moved: false + allow_trailing_slash: 'no' + generate_preview: false + objects: + versions: + steps: 10 + days: null + assets: + versions: + steps: 10 + days: null + icc_rgb_profile: '' + icc_cmyk_profile: '' + hide_edit_image: false + disable_tree_preview: true + services: + google: + client_id: '' + email: '' + simple_api_key: '' + browser_api_key: '' + cache: + exclude_cookie: '' + enabled: true + lifetime: null + exclude_patterns: '' + httpclient: + adapter: Socket + proxy_host: '' + proxy_port: '' + proxy_user: '' + proxy_pass: '' + email: + sender: + name: '' + email: '' + return: + name: '' + email: '' + method: sendmail + debug: + email_addresses: null + newsletter: + sender: + name: '' + email: '' + return: + name: '' + email: '' + method: sendmail + use_specific: false + debug: + email_addresses: null + webservice: + enabled: false + applicationlog: + mail_notification: + send_log_summary: false + filter_priority: null + mail_receiver: '' + archive_treshold: '30' + archive_alternative_database: '' +pimcore_admin: + branding: + color_login_screen: '' + color_admin_interface: '' + login_screen_custom_image: '' + login_screen_invert_colors: false +swiftmailer: + mailers: + pimcore_mailer: + transport: sendmail + delivery_addresses: { } + host: '' + username: '' + password: '' + port: '' + encryption: null + auth_mode: null + newsletter_mailer: + transport: sendmail + delivery_addresses: { } + host: '' + username: '' + password: '' + port: '' + encryption: null + auth_mode: null diff --git a/tests/_etc/travis/install b/tests/_etc/travis/install index 9c83978..65d463b 100755 --- a/tests/_etc/travis/install +++ b/tests/_etc/travis/install @@ -70,11 +70,11 @@ mv -nv GeoLite2-City.mmdb var/config/ ## install composer dependencies +rm composer.lock +COMPOSER_MEMORY_LIMIT=-1 composer require symfony/symfony:$SYMFONY_VERSION phpstan/phpstan:^0.11.1 phpstan/phpstan-symfony:^0.11.0 symplify/easy-coding-standard:^5.4 --no-scripts --no-interaction --no-update COMPOSER_MEMORY_LIMIT=-1 composer install --no-scripts -COMPOSER_MEMORY_LIMIT=-1 composer require phpstan/phpstan:^0.11.1 phpstan/phpstan-symfony:^0.11.0 symplify/easy-coding-standard:^5.4 --no-scripts - ## install $DACHCOM_BUNDLE_NAME dependencies BRANCH_REGEX="^(([[:digit:]]+\.)+[[:digit:]]+)$"