From 14287754c50eb4d4a078b7290e014f870198ae87 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Fri, 2 Aug 2024 12:10:50 +0200 Subject: [PATCH 1/4] Update sources to manage 1.13 compatibility --- .github/workflows/recipe.yaml | 67 +++++++------------ .github/workflows/security.yaml | 23 ++++--- .github/workflows/tests.yaml | 26 ++++--- .php-cs-fixer.dist.php | 29 ++++---- .php-version.dist | 2 +- Makefile | 15 ++++- README.md | 23 ++++++- composer.json | 61 ++++++----------- dist/.env.local | 1 + .../monsieurbiz_sylius_homepage_plugin.yaml | 2 - .../monsieurbiz_sylius_homepage_plugin.yaml | 18 ----- phpstan.neon | 15 ++--- recipes/1.0-dev | 1 - .../monsieurbiz_sylius_homepage_plugin.yaml | 2 - .../monsieurbiz_sylius_homepage_plugin.yaml | 18 ----- recipes/dev/manifest.json | 10 --- src/DependencyInjection/Configuration.php | 12 +--- 17 files changed, 127 insertions(+), 198 deletions(-) create mode 100644 dist/.env.local delete mode 100644 dist/config/packages/monsieurbiz_sylius_homepage_plugin.yaml delete mode 100644 dist/config/routes/monsieurbiz_sylius_homepage_plugin.yaml delete mode 120000 recipes/1.0-dev delete mode 100644 recipes/dev/config/packages/monsieurbiz_sylius_homepage_plugin.yaml delete mode 100644 recipes/dev/config/routes/monsieurbiz_sylius_homepage_plugin.yaml delete mode 100644 recipes/dev/manifest.json diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index 6faaeb9..e18d0f6 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -11,27 +11,18 @@ jobs: runs-on: ubuntu-latest - env: - SYMFONY_ENDPOINT: http://127.0.0.1/ - strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] - sylius: ['~1.8.0', '~1.9.0', '~1.10.0', '~1.11.0', '~1.12.0'] + php: ['8.0', '8.1', '8.2'] + sylius: ["~1.11.0", "~1.12.0", "~1.13.0"] exclude: - - php: '8.0' - sylius: '~1.8.0' - - php: '8.0' - sylius: '~1.9.0' - - php: '8.1' - sylius: '~1.8.0' - - php: '8.1' - sylius: '~1.9.0' - - php: '7.4' + - php: '8.2' sylius: '~1.11.0' - - php: '7.4' + - php: '8.0' sylius: '~1.12.0' + - php: '8.0' + sylius: '~1.13.0' steps: - name: Setup PHP @@ -40,33 +31,31 @@ jobs: php-version: ${{ matrix.php }} extensions: gd, intl, json ini-values: date.timezone=UTC + tools: symfony-cli - name: Set project php-version run: | - echo "${{ matrix.php }}" > .php-version + echo ${{ matrix.php }} > .php-version - uses: actions/checkout@v3 with: path: plugin - # Run the server at the start so it can download the recipes! - - name: Run standalone symfony flex server - run: | - echo ${{ github.token }} | docker login docker.pkg.github.com -u ${{ github.actor }} --password-stdin - docker run --rm --name flex -d -v $PWD/plugin/recipes:/var/www/flex/var/repo/private/monsieurbiz/sylius-homepage-plugin -p 80:80 docker.pkg.github.com/monsieurbiz/docker/symfony-flex-server:latest contrib official - docker ps + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - - uses: actions/cache@v3 + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache - key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }} + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ hashFiles('**/composer.json') }} restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}- - - name: Update composer - run: sudo composer self-update + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} @@ -85,20 +74,14 @@ jobs: working-directory: ./sylius run: | composer config --no-plugins allow-plugins true + composer config --no-plugins extra.symfony.allow-contrib true + composer config --no-plugins secure-http false + composer config --no-plugins --unset platform.php + composer config --no-plugins extra.symfony.docker false + composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' composer config repositories.plugin '{"type": "path", "url": "../plugin/"}' - composer config extra.symfony.allow-contrib true - composer config secure-http false - composer config --unset platform.php - - name: Require plugin without install + - name: Require plugin & install all dependencies working-directory: ./sylius run: | - composer require --no-install --no-scripts monsieurbiz/sylius-homepage-plugin="*@dev" - - - name: Composer install - working-directory: ./sylius - run: | - composer install - - - name: Show flex server logs - run: docker logs --tail 100 flex + composer require monsieurbiz/sylius-homepage-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index cf7c34c..c100cfa 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -13,7 +13,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['7.4', '8.0', '8.1'] + php: ['8.1', '8.2'] steps: - uses: actions/checkout@v3 @@ -23,30 +23,31 @@ jobs: with: php-version: ${{ matrix.php }} extensions: gd, intl, json - ini-values: date.timezone=UTC - name: Set project php-version run: | echo "${{ matrix.php }}" > .php-version - - uses: actions/cache@v3 + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache + path: ${{ steps.composer-cache-directory.outputs.directory }} key: composer2-php:${{ matrix.php }}-${{ github.sha }} restore-keys: composer2-php:${{ matrix.php }}- - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - - name: Update composer - run: sudo composer self-update + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} - - uses: actions/checkout@v3 - - name: Install PHP dependencies run: composer update --prefer-dist - - uses: symfonycorp/security-checker-action@v3 + - uses: symfonycorp/security-checker-action@v4 + diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d98d236..877ce6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -14,7 +14,7 @@ jobs: strategy: fail-fast: false matrix: - php: ['8.0', '8.1'] + php: ['8.1', '8.2'] env: SYMFONY_ARGS: --no-tls @@ -22,38 +22,36 @@ jobs: DOCKER_INTERACTIVE_ARGS: -t steps: - - uses: actions/checkout@v3 - - uses: actions/setup-node@v3 + - uses: actions/checkout@v2 + - uses: actions/setup-node@v2 with: node-version: '14' - - name: Setup PHP uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php }} extensions: gd, intl, json ini-values: date.timezone=UTC + tools: symfony-cli - name: Set project php-version run: | echo "${{ matrix.php }}" > .php-version - - name: Install symfony CLI - run: | - curl -1sLf 'https://dl.cloudsmith.io/public/symfony/stable/setup.deb.sh' | sudo -E bash - sudo apt install symfony-cli + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3 + - name: Cache dependencies installed with composer + uses: actions/cache@v3 id: cache-composer with: - path: /home/runner/.composer/cache + path: ${{ steps.composer-cache-directory.outputs.directory }} key: composer2-php:${{ matrix.php }}-${{ github.sha }} restore-keys: composer2-php:${{ matrix.php }}- - - run: mkdir -p /home/runner/{.composer/cache,.config/composer} - - - name: Update composer - run: sudo composer self-update + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - name: Composer Github Auth run: composer config -g github-oauth.github.com ${{ github.token }} diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index a402e73..141f51a 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -49,10 +49,8 @@ 'binary_operator_spaces' => true, 'blank_line_after_opening_tag' => true, 'blank_line_after_namespace' => true, + 'blank_lines_before_namespace' => true, 'blank_line_before_statement' => true, - 'braces' => [ - 'allow_single_line_closure' => true, - ], 'cast_spaces' => true, 'class_attributes_separation' => true, 'class_definition' => [ @@ -62,7 +60,7 @@ 'combine_consecutive_issets' => true, 'combine_consecutive_unsets' => true, 'comment_to_phpdoc' => true, - 'compact_nullable_typehint' => true, + 'compact_nullable_type_declaration' => true, 'concat_space' => [ 'spacing' => 'one', ], @@ -88,8 +86,12 @@ 'fully_qualified_strict_types' => true, 'function_declaration' => true, 'function_to_constant' => true, - 'function_typehint_space' => true, 'general_phpdoc_tag_rename' => true, + 'global_namespace_import' => [ + 'import_classes' => true, + 'import_constants' => false, + 'import_functions' => false, + ], 'header_comment' => [ 'header' => $header, 'location' => 'after_open', @@ -110,6 +112,7 @@ 'lowercase_static_reference' => true, 'magic_constant_casing' => true, 'method_argument_space' => true, + 'modernize_strpos' => false, 'modernize_types_casting' => true, 'multiline_comment_opening_closing' => true, 'multiline_whitespace_before_semicolons' => [ @@ -117,7 +120,7 @@ ], 'native_constant_invocation' => true, 'native_function_casing' => true, - 'new_with_braces' => true, + 'new_with_parentheses' => true, 'no_alias_functions' => true, 'no_alternative_syntax' => true, 'no_blank_lines_after_class_opening' => true, @@ -156,27 +159,27 @@ 'no_short_bool_cast' => true, 'no_spaces_after_function_name' => true, 'no_spaces_around_offset' => true, - 'no_spaces_inside_parenthesis' => true, + 'spaces_inside_parentheses' => true, 'no_superfluous_elseif' => true, 'no_superfluous_phpdoc_tags' => [ 'allow_mixed' => true, ], 'no_unset_cast' => true, 'no_unneeded_control_parentheses' => true, - 'no_unneeded_curly_braces' => true, + 'no_unneeded_braces' => true, 'no_unneeded_final_method' => true, 'no_unset_on_property' => true, 'no_unused_imports' => true, 'no_useless_else' => true, 'no_useless_return' => true, - 'no_trailing_comma_in_list_call' => true, - 'no_trailing_comma_in_singleline_array' => true, + 'no_trailing_comma_in_singleline' => true, 'no_trailing_whitespace' => true, 'no_trailing_whitespace_in_comment' => true, 'no_whitespace_before_comma_in_array' => true, 'no_whitespace_in_blank_line' => true, 'non_printable_character' => true, 'normalize_index_brace' => true, + 'nullable_type_declaration_for_default_null_value' => false, 'object_operator_without_whitespace' => true, 'ordered_imports' => [ 'imports_order' => [ @@ -211,7 +214,9 @@ 'phpdoc_order' => true, 'phpdoc_return_self_reference' => true, 'phpdoc_scalar' => true, - 'phpdoc_separation' => true, + 'phpdoc_separation' => ['groups' => [ + ['ORM\\*'], ['Assert\\*'], + ]], 'phpdoc_single_line_var_spacing' => true, 'phpdoc_tag_type' => true, 'phpdoc_to_comment' => false, @@ -231,7 +236,6 @@ 'self_accessor' => true, 'short_scalar_cast' => true, 'single_blank_line_at_eof' => true, - 'single_blank_line_before_namespace' => true, 'single_class_element_per_statement' => true, 'single_import_per_statement' => true, 'single_line_after_imports' => true, @@ -248,6 +252,7 @@ 'elements' => ['arrays'], ], 'trim_array_spaces' => true, + 'type_declaration_spaces' => true, 'unary_operator_spaces' => true, 'visibility_required' => [ 'elements' => [ diff --git a/.php-version.dist b/.php-version.dist index b8eb026..2983cad 100644 --- a/.php-version.dist +++ b/.php-version.dist @@ -1 +1 @@ -8.1 +8.2 diff --git a/Makefile b/Makefile index 8b2853d..905343a 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,13 @@ .DEFAULT_GOAL := help SHELL=/bin/bash APP_DIR=tests/Application -SYLIUS_VERSION=1.12.0 +SYLIUS_VERSION=1.13.0 SYMFONY=cd ${APP_DIR} && symfony COMPOSER=symfony composer CONSOLE=${SYMFONY} console export COMPOSE_PROJECT_NAME=homepage +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusHomepagePlugin\\Migrations +export USER_UID=$(shell id -u) PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin COMPOSE=docker-compose YARN=yarn @@ -69,18 +71,22 @@ setup_application: (cd ${APP_DIR} && ${COMPOSER} config repositories.plugin '{"type": "path", "url": "../../"}') (cd ${APP_DIR} && ${COMPOSER} config extra.symfony.allow-contrib true) (cd ${APP_DIR} && ${COMPOSER} config minimum-stability dev) + (cd ${APP_DIR} && ${COMPOSER} config --no-plugins allow-plugins true) + (cd ${APP_DIR} && ${COMPOSER} config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]') (cd ${APP_DIR} && ${COMPOSER} require --no-install --no-scripts --no-progress sylius/sylius="~${SYLIUS_VERSION}") # Make sure to install the required version of sylius because the sylius-standard has a soft constraint $(MAKE) ${APP_DIR}/.php-version $(MAKE) ${APP_DIR}/php.ini (cd ${APP_DIR} && ${COMPOSER} install --no-interaction) $(MAKE) apply_dist - (cd ${APP_DIR} && ${COMPOSER} require --no-interaction --no-progress monsieurbiz/${PLUGIN_NAME}="*@dev") + (cd ${APP_DIR} && ${COMPOSER} require --no-progress --no-interaction monsieurbiz/${PLUGIN_NAME}="*@dev") rm -rf ${APP_DIR}/var/cache ${APP_DIR}/docker-compose.yaml: rm -f ${APP_DIR}/docker-compose.yml rm -f ${APP_DIR}/docker-compose.yaml + rm -f ${APP_DIR}/compose.yml # Remove Sylius file about Docker + rm -f ${APP_DIR}/compose.override.dist.yml # Remove Sylius file about Docker ln -s ../../docker-compose.yaml.dist ${APP_DIR}/docker-compose.yaml .PHONY: ${APP_DIR}/docker-compose.yaml @@ -132,7 +138,7 @@ test.container: ## Lint the symfony container ${CONSOLE} lint:container test.yaml: ## Lint the symfony Yaml files - ${CONSOLE} lint:yaml ../../recipes ../../src/Resources/config + ${CONSOLE} lint:yaml ../../src/Resources/config --parse-tags test.schema: ## Validate MySQL Schema ${CONSOLE} doctrine:schema:validate @@ -163,6 +169,9 @@ sylius.assets: ## Install all assets with symlinks messenger.setup: ## Setup Messenger transports ${CONSOLE} messenger:setup-transports +doctrine.diff: ## Doctrine diff + ${CONSOLE} doctrine:migration:diff --namespace="${MIGRATIONS_NAMESPACE}" + ### ### PLATFORM ### ¯¯¯¯¯¯¯¯ diff --git a/README.md b/README.md index 4fb164e..4c25f47 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,12 @@ [![Banner of Sylius Homepages plugin](docs/images/banner.jpg)](https://monsieurbiz.com/agence-web-experte-sylius) -

Homepages

+

Sylius Homepages

[![Homepage Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusHomepagePlugin?public)](https://github.com/monsieurbiz/SyliusHomepagePlugin/blob/master/LICENSE.txt) -[![Build Status](https://img.shields.io/github/workflow/status/monsieurbiz/SyliusHomepagePlugin/Tests)](https://github.com/monsieurbiz/SyliusHomepagePlugin/actions?query=workflow%3ATests) +[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusHomepagePlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusHomepagePlugin/actions?query=workflow%3ATests) +[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusHomepagePlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusHomepagePlugin/actions?query=workflow%3ASecurity) +[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusHomepagePlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusHomepagePlugin/actions?query=workflow%3ASecurity) + This plugins allows you to manage your homepages using the Rich Editor. @@ -11,12 +14,28 @@ If you want to know more about our editor, see the [Rich Editor Repository](http ![Example of homepage edition](screenshots/demo.gif) +## Compatibility + +| Sylius Version | PHP Version | +|---|---| +| 1.11 | 8.0 - 8.1 | +| 1.12 | 8.1 - 8.2 | +| 1.13 | 8.1 - 8.2 | + ## Installation +If you want to use our recipes, you can configure your composer.json by running: + +```bash +composer config --no-plugins --json extra.symfony.endpoint '["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master","flex://defaults"]' +``` + ```bash composer require monsieurbiz/sylius-homepage-plugin ``` +If you do not use the recipes : + Change your `config/bundles.php` file to add the line for the plugin : ```php diff --git a/composer.json b/composer.json index 0c0beeb..dd3d2b6 100644 --- a/composer.json +++ b/composer.json @@ -5,46 +5,19 @@ "description": "Add a homepage management to your Sylius using the Rich Editor.", "license": "MIT", "require": { - "php": "~7.4|~8.0", - "sylius/sylius": ">=1.8 <1.13", - "gedmo/doctrine-extensions": "^2.4.12 || ^3.0", - "monsieurbiz/sylius-rich-editor-plugin": "^2.2", - "monsieurbiz/sylius-plus-adapter-plugin": "^1.0" + "monsieurbiz/sylius-plus-adapter-plugin": "^1.1", + "monsieurbiz/sylius-rich-editor-plugin": "^2.8", + "php": "^8.0", + "sylius/sylius": ">=1.11 <1.14" }, "require-dev": { - "behat/behat": "^3.6.1", - "behat/mink-selenium2-driver": "^1.4", - "dmore/behat-chrome-extension": "^1.3", - "dmore/chrome-mink-driver": "^2.7", - "doctrine/data-fixtures": "^1.4", - "ergebnis/composer-normalize": "^2.5", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-extension": "^2.4", - "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", - "hwi/oauth-bundle": "^1.1", - "lchrusciel/api-test-case": "^5.0", - "matthiasnoback/symfony-config-test": "^4.2", - "matthiasnoback/symfony-dependency-injection-test": "^4.1", - "mikey179/vfsstream": "^1.6", - "mockery/mockery": "^1.4", - "pamil/prophecy-common": "^0.1", - "phpspec/phpspec": "^6.1|^7.2", - "phpstan/phpstan": "^0.12.57", - "phpstan/phpstan-doctrine": "^0.12.19", - "phpstan/phpstan-webmozart-assert": "^0.12.7", - "phpunit/phpunit": "^8.5", - "psalm/plugin-mockery": "^0.3", - "psr/event-dispatcher": "^1.0", - "sylius-labs/coding-standard": "^3.1", - "symfony/browser-kit": "^4.4", - "symfony/debug-bundle": "^4.4", - "symfony/dotenv": "^4.4", - "symfony/flex": "^1.7", - "symfony/web-profiler-bundle": "^4.4", - "phpmd/phpmd": "@stable" + "friendsofphp/php-cs-fixer": "^3.16", + "phpspec/phpspec": "^7.0", + "phpstan/phpstan": "^1.8.4", + "phpstan/phpstan-doctrine": "^1.3.2", + "phpstan/phpstan-webmozart-assert": "^1.1", + "phpunit/phpunit": "^10.5", + "phpmd/phpmd": "^2.15" }, "prefer-stable": true, "autoload": { @@ -57,7 +30,7 @@ "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, - "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=false", + "phpcs": "PHP_CS_FIXER_IGNORE_ENV=1 php-cs-fixer fix --using-cache=no", "phpstan": "phpstan analyse -c phpstan.neon src/", "phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml", "phpunit": "phpunit", @@ -65,15 +38,19 @@ }, "extra": { "branch-alias": { - "dev-master": "1.0-dev" + "dev-master": "1.2-dev" + }, + "symfony": { + "docker": false, + "endpoint": ["https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", "flex://defaults"] } }, "config": { "allow-plugins": { - "dealerdirect/phpcodesniffer-composer-installer": true, "symfony/thanks": true, - "ergebnis/composer-normalize": true, "symfony/flex": true, + "dealerdirect/phpcodesniffer-composer-installer": true, + "ergebnis/composer-normalize": true, "php-http/discovery": true } } diff --git a/dist/.env.local b/dist/.env.local new file mode 100644 index 0000000..6c1a99e --- /dev/null +++ b/dist/.env.local @@ -0,0 +1 @@ +SYLIUS_FIXTURES_HOSTNAME=${SYMFONY_DEFAULT_ROUTE_HOST:-localhost} diff --git a/dist/config/packages/monsieurbiz_sylius_homepage_plugin.yaml b/dist/config/packages/monsieurbiz_sylius_homepage_plugin.yaml deleted file mode 100644 index d082ad0..0000000 --- a/dist/config/packages/monsieurbiz_sylius_homepage_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@MonsieurBizSyliusHomepagePlugin/Resources/config/config.yaml" } diff --git a/dist/config/routes/monsieurbiz_sylius_homepage_plugin.yaml b/dist/config/routes/monsieurbiz_sylius_homepage_plugin.yaml deleted file mode 100644 index 487ca47..0000000 --- a/dist/config/routes/monsieurbiz_sylius_homepage_plugin.yaml +++ /dev/null @@ -1,18 +0,0 @@ -monsieurbiz_sylius_homepage_admin: - resource: "@MonsieurBizSyliusHomepagePlugin/Resources/config/routes/admin.yaml" - prefix: /%sylius_admin.path_name% - -monsieurbiz_sylius_homepage_homepage: - path: /{_locale}/ - methods: [GET] - requirements: - _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ - defaults: - _controller: monsieurbiz_homepage.controller.homepage::indexAction - _sylius: - template: '@MonsieurBizSyliusHomepagePlugin/Homepage/index.html.twig' - repository: - method: findOneByChannelAndLocale - arguments: - - "expr:service('sylius.context.channel').getChannel()" - - "expr:service('sylius.context.locale').getLocaleCode()" diff --git a/phpstan.neon b/phpstan.neon index a68a823..32dd8eb 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,18 +1,15 @@ -includes: - - vendor/phpstan/phpstan-doctrine/extension.neon - - vendor/phpstan/phpstan-webmozart-assert/extension.neon - parameters: - level: max + level: 8 paths: - %rootDir%/src/ - checkMissingIterableValueType: false - - excludes_analyse: + excludePaths: # Makes PHPStan crash - - 'src/DependencyInjection/Configuration.php' - 'src/DependencyInjection/MonsieurBizSyliusHomepageExtension.php' # Test dependencies - 'tests/Application/**/*' + + ignoreErrors: + - identifier: missingType.generics + - identifier: missingType.iterableValue diff --git a/recipes/1.0-dev b/recipes/1.0-dev deleted file mode 120000 index 9001211..0000000 --- a/recipes/1.0-dev +++ /dev/null @@ -1 +0,0 @@ -dev \ No newline at end of file diff --git a/recipes/dev/config/packages/monsieurbiz_sylius_homepage_plugin.yaml b/recipes/dev/config/packages/monsieurbiz_sylius_homepage_plugin.yaml deleted file mode 100644 index d082ad0..0000000 --- a/recipes/dev/config/packages/monsieurbiz_sylius_homepage_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - - { resource: "@MonsieurBizSyliusHomepagePlugin/Resources/config/config.yaml" } diff --git a/recipes/dev/config/routes/monsieurbiz_sylius_homepage_plugin.yaml b/recipes/dev/config/routes/monsieurbiz_sylius_homepage_plugin.yaml deleted file mode 100644 index 487ca47..0000000 --- a/recipes/dev/config/routes/monsieurbiz_sylius_homepage_plugin.yaml +++ /dev/null @@ -1,18 +0,0 @@ -monsieurbiz_sylius_homepage_admin: - resource: "@MonsieurBizSyliusHomepagePlugin/Resources/config/routes/admin.yaml" - prefix: /%sylius_admin.path_name% - -monsieurbiz_sylius_homepage_homepage: - path: /{_locale}/ - methods: [GET] - requirements: - _locale: ^[a-z]{2}(?:_[A-Z]{2})?$ - defaults: - _controller: monsieurbiz_homepage.controller.homepage::indexAction - _sylius: - template: '@MonsieurBizSyliusHomepagePlugin/Homepage/index.html.twig' - repository: - method: findOneByChannelAndLocale - arguments: - - "expr:service('sylius.context.channel').getChannel()" - - "expr:service('sylius.context.locale').getLocaleCode()" diff --git a/recipes/dev/manifest.json b/recipes/dev/manifest.json deleted file mode 100644 index 2f90df5..0000000 --- a/recipes/dev/manifest.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "bundles": { - "MonsieurBiz\\SyliusHomepagePlugin\\MonsieurBizSyliusHomepagePlugin": [ - "all" - ] - }, - "copy-from-recipe": { - "config/": "%CONFIG_DIR%/" - } -} diff --git a/src/DependencyInjection/Configuration.php b/src/DependencyInjection/Configuration.php index c22e7aa..8c2ed48 100644 --- a/src/DependencyInjection/Configuration.php +++ b/src/DependencyInjection/Configuration.php @@ -23,16 +23,6 @@ final class Configuration implements ConfigurationInterface */ public function getConfigTreeBuilder(): TreeBuilder { - $treeBuilder = new TreeBuilder('monsieurbiz_sylius_homepage'); - if (method_exists($treeBuilder, 'getRootNode')) { - $treeBuilder->getRootNode(); - - return $treeBuilder; - } - - // BC layer for symfony/config 4.1 and older - $treeBuilder->root('monsieurbiz_sylius_homepage'); - - return $treeBuilder; + return new TreeBuilder('monsieurbiz_sylius_homepage'); } } From 17df26d4ae65a34a27ff629f10c77882080e9279 Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Fri, 2 Aug 2024 12:23:09 +0200 Subject: [PATCH 2/4] Fix filters and sortings in grids in admin --- src/Resources/config/sylius/grid.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/Resources/config/sylius/grid.yaml b/src/Resources/config/sylius/grid.yaml index 1124fae..04ab0cb 100644 --- a/src/Resources/config/sylius/grid.yaml +++ b/src/Resources/config/sylius/grid.yaml @@ -5,7 +5,12 @@ sylius_grid: name: doctrine/orm options: class: '%monsieurbiz_homepage.model.homepage.class%' + repository: + method: createListQueryBuilder + arguments: ["%locale%"] limits: [25, 50, 100, 200] + sorting: + id: desc fields: id: type: string @@ -34,9 +39,13 @@ sylius_grid: name: type: string label: monsieurbiz_homepage.ui.form.name + options: + fields: [ translation.name ] content: type: string label: monsieurbiz_homepage.ui.form.content + options: + fields: [ translation.content ] channel: type: entity label: sylius.ui.channel From 68e740e25d5993554f80c607ce1a683b42902fff Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Fri, 2 Aug 2024 12:23:56 +0200 Subject: [PATCH 3/4] Remove unused attribute in Admin menu listener --- src/Menu/AdminMenuListener.php | 13 ------------- 1 file changed, 13 deletions(-) diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php index fb55110..4709dfe 100644 --- a/src/Menu/AdminMenuListener.php +++ b/src/Menu/AdminMenuListener.php @@ -18,19 +18,6 @@ final class AdminMenuListener { - /** - * @var MenuManipulator - */ - private $manipulator; - - /** - * AdminMenuListener constructor. - */ - public function __construct(MenuManipulator $manipulator) - { - $this->manipulator = $manipulator; - } - public function addAdminMenuItem(MenuBuilderEvent $event): void { $menu = $event->getMenu(); From 8dd7d17cb66c7ae50aabc83f41ae6f4ae1461c3e Mon Sep 17 00:00:00 2001 From: Maxime Huran Date: Fri, 2 Aug 2024 12:24:09 +0200 Subject: [PATCH 4/4] Fix PHP CS --- src/Entity/Homepage.php | 1 - src/Menu/AdminMenuListener.php | 1 - src/Repository/HomepageRepository.php | 2 +- 3 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/Entity/Homepage.php b/src/Entity/Homepage.php index e1f9fdf..bc2eb39 100644 --- a/src/Entity/Homepage.php +++ b/src/Entity/Homepage.php @@ -25,7 +25,6 @@ class Homepage implements HomepageInterface { use TimestampableTrait; - use TranslatableTrait { __construct as private initializeTranslationsCollection; diff --git a/src/Menu/AdminMenuListener.php b/src/Menu/AdminMenuListener.php index 4709dfe..f1b8405 100644 --- a/src/Menu/AdminMenuListener.php +++ b/src/Menu/AdminMenuListener.php @@ -13,7 +13,6 @@ namespace MonsieurBiz\SyliusHomepagePlugin\Menu; -use Knp\Menu\Util\MenuManipulator; use Sylius\Bundle\UiBundle\Menu\Event\MenuBuilderEvent; final class AdminMenuListener diff --git a/src/Repository/HomepageRepository.php b/src/Repository/HomepageRepository.php index cbe734d..c80feab 100644 --- a/src/Repository/HomepageRepository.php +++ b/src/Repository/HomepageRepository.php @@ -43,6 +43,6 @@ public function findOneByChannelAndLocale(ChannelInterface $channel, string $loc ->setParameter('locale', $locale) ->getQuery() ->getOneOrNullResult() - ; + ; } }