diff --git a/.github/workflows/recipe.yaml b/.github/workflows/recipe.yaml index ec35fe8..f737bd4 100644 --- a/.github/workflows/recipe.yaml +++ b/.github/workflows/recipe.yaml @@ -1,82 +1,87 @@ name: Flex Recipe on: - push: - branches: [ master ] - pull_request: + push: + branches: [ master ] + pull_request: jobs: - recipe: - - name: Flex recipe (PHP ${{ matrix.php }}, Sylius ${{ matrix.sylius }}) - - runs-on: ubuntu-latest - - strategy: - fail-fast: false - matrix: - php: ['8.2'] - sylius: ["~1.12.0"] - - steps: - - 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 - - - uses: actions/checkout@v3 - with: - path: plugin - - - name: Determine composer cache directory - id: composer-cache-directory - working-directory: plugin - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - 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: 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 }} - - - name: Create Sylius-Standard project without install - run: | - composer create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard sylius "${{ matrix.sylius }}" - - # Because the sylius-standard has a soft constraint - - name: Make sure to install the required version of Sylius - working-directory: ./sylius - run: | - composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}" - - - name: Setup some requirements - 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/"}' - - - name: Require plugin & install all dependencies - working-directory: ./sylius - run: | - composer require monsieurbiz/sylius-better-admin-plugin="*@dev" + recipe: + + runs-on: ubuntu-latest + + strategy: + fail-fast: false + matrix: + php: ['8.0', '8.1', '8.2'] + sylius: ["~1.11.0", "~1.12.0", "~1.13.0"] + exclude: + - php: '8.2' + sylius: '~1.11.0' + - php: '8.0' + sylius: '~1.12.0' + - php: '8.0' + sylius: '~1.13.0' + + steps: + - 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 + + - uses: actions/checkout@v3 + with: + path: plugin + + - name: Determine composer cache directory + id: composer-cache-directory + working-directory: plugin + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + + - name: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + 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: 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 }} + + - name: Create Sylius-Standard project without install + run: | + composer create-project --prefer-dist --no-scripts --no-progress --no-install sylius/sylius-standard sylius "${{ matrix.sylius }}" + + # Because the sylius-standard has a soft constraint + - name: Make sure to install the required version of Sylius + working-directory: ./sylius + run: | + composer require --no-install --no-scripts --no-progress sylius/sylius="${{ matrix.sylius }}" + + - name: Setup some requirements + 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/"}' + + - name: Require plugin & install all dependencies + working-directory: ./sylius + run: | + composer require monsieurbiz/sylius-better-admin-plugin="*@dev" diff --git a/.github/workflows/security.yaml b/.github/workflows/security.yaml index 8167db5..c100cfa 100644 --- a/.github/workflows/security.yaml +++ b/.github/workflows/security.yaml @@ -1,55 +1,53 @@ name: Security on: - push: - pull_request: + push: + pull_request: jobs: - security: + security: - name: Security check (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2'] - strategy: - fail-fast: false - matrix: - php: ['8.2'] + steps: + - uses: actions/checkout@v3 - steps: - - uses: actions/checkout@v3 + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + php-version: ${{ matrix.php }} + extensions: gd, intl, json - - name: Setup PHP - uses: shivammathur/setup-php@v2 - 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 - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - 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: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - path: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- - - name: Ensure that composer cache directory exists - run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + - 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 }} + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - - name: Install PHP dependencies - run: composer update --prefer-dist + - name: Install PHP dependencies + run: composer update --prefer-dist - - uses: symfonycorp/security-checker-action@v4 + - uses: symfonycorp/security-checker-action@v4 diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 501ea6c..877ce6a 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -1,78 +1,79 @@ name: Tests on: - push: - branches: [ master ] - pull_request: + push: + branches: [ master ] + pull_request: jobs: - php: + php: - name: Quality tests (PHP ${{ matrix.php }}) + runs-on: ubuntu-latest - runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + php: ['8.1', '8.2'] - strategy: - fail-fast: false - matrix: - php: ['8.2'] + env: + SYMFONY_ARGS: --no-tls + COMPOSER_ARGS: --prefer-dist + DOCKER_INTERACTIVE_ARGS: -t - env: - COMPOSER_ARGS: --prefer-dist - DOCKER_INTERACTIVE_ARGS: -t + steps: + - 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 - steps: - - uses: actions/checkout@v3 + - name: Set project php-version + run: | + echo "${{ matrix.php }}" > .php-version - - uses: actions/setup-node@v3 - with: - node-version: '16' + - name: Determine composer cache directory + id: composer-cache-directory + run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT - - 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: Cache dependencies installed with composer + uses: actions/cache@v3 + id: cache-composer + with: + path: ${{ steps.composer-cache-directory.outputs.directory }} + key: composer2-php:${{ matrix.php }}-${{ github.sha }} + restore-keys: composer2-php:${{ matrix.php }}- - - name: Set project php-version - run: | - echo ${{ matrix.php }} > .php-version + - name: Ensure that composer cache directory exists + run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} - - name: Determine composer cache directory - id: composer-cache-directory - run: echo "directory=$(composer config cache-dir)" >> $GITHUB_OUTPUT + - name: Composer Github Auth + run: composer config -g github-oauth.github.com ${{ github.token }} - - name: Cache dependencies installed with composer - uses: actions/cache@v3 - id: cache-composer - with: - path: ${{ steps.composer-cache-directory.outputs.directory }} - key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }} - restore-keys: composer2-php:${{ matrix.php }}- + - run: make install - - name: Ensure that composer cache directory exists - run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }} + - run: make test.composer - - name: Composer Github Auth - run: composer config -g github-oauth.github.com ${{ github.token }} + - run: make test.phpcs - - run: make install + - run: make test.phpunit - - run: make test.composer + - run: make test.phpstan - - run: make test.phpcs + - run: make test.phpmd - - run: make test.phpstan + - run: make test.phpspec - - run: make test.phpmd + - run: make test.yaml - - run: make test.yaml + - run: make test.twig - - run: make test.twig + - run: make test.schema - - run: make test.schema - - - run: make test.container + - run: make test.container diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index 63907e0..e21d11c 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -1,18 +1,22 @@ - * For the full copyright and license information, please view the LICENSE + * + * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ declare(strict_types=1); $header = <<<'HEADER' -This file is part of Monsieur Biz's for Sylius. +This file is part of Monsieur Biz' Better Admin plugin for Sylius. + (c) Monsieur Biz -For the full copyright and license information, please view the LICENSE + +For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code. HEADER; diff --git a/Makefile b/Makefile index 3b1f891..3a2bc3e 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,16 @@ .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=sylius_better_admin_plugin -PLUGIN_NAME=sylius-better-admin-plugin -COMPOSE=docker-compose +export COMPOSE_PROJECT_NAME=better-admin +export MIGRATIONS_NAMESPACE=MonsieurBiz\\SyliusBetterAdminPlugin\\Migrations +export USER_UID=$(shell id -u) +PLUGIN_NAME=sylius-${COMPOSE_PROJECT_NAME}-plugin +COMPOSE=docker compose YARN=yarn -DOCTRINE_MIGRATIONS_NAMESPACE=MonsieurBiz\SyliusBetterAdminPlugin\Migrations - ### ### DEVELOPMENT @@ -76,16 +76,17 @@ setup_application: (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} require --no-progress api-platform/core="2.7.16") (cd ${APP_DIR} && ${COMPOSER} install --no-interaction) $(MAKE) apply_dist - (cd ${APP_DIR} && ${COMPOSER} require --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 @@ -110,7 +111,7 @@ apply_dist: ### TESTS ### ¯¯¯¯¯ -test.all: test.composer test.phpstan test.phpmd test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once +test.all: test.composer test.phpstan test.phpmd test.phpunit test.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once test.composer: ## Validate composer.json ${COMPOSER} validate --strict @@ -121,6 +122,12 @@ test.phpstan: ## Run PHPStan test.phpmd: ## Run PHPMD ${COMPOSER} phpmd +test.phpunit: ## Run PHPUnit + ${COMPOSER} phpunit + +test.phpspec: ## Run PHPSpec + ${COMPOSER} phpspec + test.phpcs: ## Run PHP CS Fixer in dry-run ${COMPOSER} run -- phpcs --dry-run -v @@ -131,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 @@ -139,18 +146,6 @@ test.schema: ## Validate MySQL Schema test.twig: ## Validate Twig templates ${CONSOLE} lint:twig --no-debug templates/ ../../src/Resources/views/ -### -### MIGRATIONS -### ¯¯¯¯¯¯¯¯¯¯ - -doctrine.migration.diff: ## Create a diff migration file for the plugin - ${CONSOLE} doctrine:migrations:diff --namespace="${DOCTRINE_MIGRATIONS_NAMESPACE}" -.PHONY: doctrine.migration.diff - -doctrine.migration.migrate: ## Run migrations - ${CONSOLE} doctrine:migration:migrate -n -.PHONY: doctrine.migration.migrate - ### ### SYLIUS ### ¯¯¯¯¯¯ @@ -174,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 ### ¯¯¯¯¯¯¯¯ @@ -211,18 +209,6 @@ server.start: ## Run the local webserver using Symfony server.stop: ## Stop the local webserver ${SYMFONY} local:server:stop -### -### GITHUB CODESPACES -### ¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯¯ - -codespace.hostname: ${APP_DIR}/.env.local ## Init the SYLIUS_FIXTURES_HOSTNAME variable in .env.local -ifdef CODESPACES - echo SYLIUS_FIXTURES_HOSTNAME=${CODESPACE_NAME}-8000.${GITHUB_CODESPACES_PORT_FORWARDING_DOMAIN} >> ${APP_DIR}/.env.local -endif - -${APP_DIR}/.env.local: - touch ${APP_DIR}/.env.local - ### ### HELP ### ¯¯¯¯ diff --git a/README.md b/README.md index ba26e15..c8e4e86 100644 --- a/README.md +++ b/README.md @@ -1,20 +1,35 @@ -# Sylius Better Admin Plugin +

Sylius Better Admin

-## Example +[![Better Admin Plugin license](https://img.shields.io/github/license/monsieurbiz/SyliusBetterAdminPlugin?public)](https://github.com/monsieurbiz/SyliusBetterAdminPlugin/blob/master/LICENSE.txt) +[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusBetterAdminPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusBetterAdminPlugin/actions?query=workflow%3ATests) +[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusBetterAdminPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusBetterAdminPlugin/actions?query=workflow%3ASecurity) +[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusBetterAdminPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusBetterAdminPlugin/actions?query=workflow%3ASecurity) -### Login Page +This plugins allows you to customize colors, logos and background of the Sylius Admin Panel. -![Login Page](images/demo.jpg) +![Example of a customized admin panel](images/demo.jpg) -### Settings +## Compatibility -![Settings form](images/settings.jpg) +| Sylius Version | PHP Version | +|---|---| +| 1.11 | 8.0 - 8.1 | +| 1.12 | 8.1 - 8.2 | +| 1.13 | 8.1 - 8.2 | ## Installation -TBD +If you want to use our recipes, you can configure your composer.json by running: -If recipe is not ran : +```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-better-admin-plugin +``` + +You can copy the templates to customize the display of the admin panel: ``` mkdir -p templates/bundles/; @@ -23,6 +38,10 @@ cp -Rv vendor/monsieurbiz/sylius-better-admin-plugin/src/Resources/views/SyliusA cp -Rv vendor/monsieurbiz/sylius-better-admin-plugin/src/Resources/views/MonsieurBizSyliusAdminBetterLoginPlugin templates/bundles/; ``` +## Admin form + +![Example of a customized admin panel](images/settings.jpg) + ## License This plugin is under the MIT license. diff --git a/composer.json b/composer.json index 9c87477..10ff352 100644 --- a/composer.json +++ b/composer.json @@ -1,47 +1,23 @@ { "name": "monsieurbiz/sylius-better-admin-plugin", "type": "sylius-plugin", - "keywords": ["sylius", "sylius-plugin"], + "keywords": ["sylius", "sylius-plugin", "monsieurbiz"], "description": "Manage your logos, colors and backgrounds with settings in Sylius Admin pannel", "license": "MIT", "require": { - "monsieurbiz/sylius-admin-better-login-plugin": "^2.0", "monsieurbiz/sylius-media-manager-plugin": "^1.0", "monsieurbiz/sylius-settings-plugin": "^1.0", - "php": "^8.2", - "sylius/sylius": ">=1.12 <1.13" + "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", - "friends-of-behat/mink": "^1.8", - "friends-of-behat/mink-browserkit-driver": "^1.4", - "friends-of-behat/mink-debug-extension": "^2.0.0", - "friends-of-behat/mink-extension": "^2.4", - "friends-of-behat/page-object-extension": "^0.3", - "friends-of-behat/suite-settings-extension": "^1.0", - "friends-of-behat/symfony-extension": "^2.1", - "friends-of-behat/variadic-extension": "^1.3", - "phpspec/phpspec": "^7.2", - "phpstan/extension-installer": "^1.0", - "phpstan/phpstan": "^1.8.1", - "phpstan/phpstan-doctrine": "1.3.40", - "phpstan/phpstan-strict-rules": "^1.3.0", - "phpstan/phpstan-webmozart-assert": "^1.2.0", - "phpunit/phpunit": "^9.5", - "polishsymfonycommunity/symfony-mocker-container": "^1.0", - "sylius-labs/coding-standard": "^4.2", - "symfony/browser-kit": "^5.4 || ^6.0", - "symfony/debug-bundle": "^5.4 || ^6.0", - "symfony/dotenv": "^5.4 || ^6.0", - "symfony/flex": "^2.2.2", - "symfony/intl": "^5.4 || ^6.0", - "symfony/web-profiler-bundle": "^5.4 || ^6.0", - "vimeo/psalm": "5.12.0", - "phpmd/phpmd": "^2.13", - "friendsofphp/php-cs-fixer": "^3.16" + "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": { @@ -54,32 +30,28 @@ "cache:clear": "symfony-cmd", "assets:install %PUBLIC_DIR%": "symfony-cmd" }, - "phpcs": "php-cs-fixer fix --using-cache=no", + "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", "phpspec": "phpspec run" }, "extra": { + "branch-alias": { + "dev-master": "1.1-dev" + }, "symfony": { "docker": false, - "endpoint": [ - "https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master", - "flex://defaults" - ] - }, - "branch-alias": { - "dev-master": "1.0-dev" + "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, - "php-http/discovery": false, - "phpstan/extension-installer": 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_better_admin_plugin.yaml b/dist/config/packages/monsieurbiz_sylius_better_admin_plugin.yaml deleted file mode 100644 index 2c72b60..0000000 --- a/dist/config/packages/monsieurbiz_sylius_better_admin_plugin.yaml +++ /dev/null @@ -1,2 +0,0 @@ -imports: - resource: '@MonsieurBizSyliusBetterAdminPlugin/Resources/config/config.yaml' diff --git a/dist/src/Migrations/.gitignore b/dist/src/Migrations/.gitignore deleted file mode 100644 index e69de29..0000000 diff --git a/images/demo.jpg b/images/demo.jpg index 736a65b..4ce687d 100644 Binary files a/images/demo.jpg and b/images/demo.jpg differ diff --git a/images/settings.jpg b/images/settings.jpg index 6c0f3d5..134b95e 100644 Binary files a/images/settings.jpg and b/images/settings.jpg differ diff --git a/phpstan.neon b/phpstan.neon index d633111..44f4bd2 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,14 +1,15 @@ parameters: - level: max + level: 8 paths: - %rootDir%/src/ - checkMissingIterableValueType: false - checkGenericClassInNonGenericObjectType: false - excludePaths: # Makes PHPStan crash - 'src/DependencyInjection/SyliusBetterAdminExtension.php' # Test dependencies - 'tests/Application/**/*' + + ignoreErrors: + # - identifier: missingType.generics + - identifier: missingType.iterableValue diff --git a/src/DependencyInjection/MonsieurBizSyliusBetterAdminExtension.php b/src/DependencyInjection/MonsieurBizSyliusBetterAdminExtension.php index a993b2c..d21e004 100644 --- a/src/DependencyInjection/MonsieurBizSyliusBetterAdminExtension.php +++ b/src/DependencyInjection/MonsieurBizSyliusBetterAdminExtension.php @@ -1,9 +1,11 @@ - * For the full copyright and license information, please view the LICENSE + * + * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Form/Type/Settings/AdminSettingsType.php b/src/Form/Type/Settings/AdminSettingsType.php index 4d186b2..6145b76 100644 --- a/src/Form/Type/Settings/AdminSettingsType.php +++ b/src/Form/Type/Settings/AdminSettingsType.php @@ -1,9 +1,11 @@ - * For the full copyright and license information, please view the LICENSE + * + * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -26,26 +28,6 @@ class AdminSettingsType extends AbstractSettingsType implements SettingsTypeInte */ public function buildForm(FormBuilderInterface $builder, array $options): void { - $this->addWithDefaultCheckbox( - $builder, - 'color', - ColorType::class, - [ - 'label' => 'monsieurbiz_better_admin.form.color', - 'help' => 'monsieurbiz_better_admin.form.color_help', - 'required' => false, - ] - ); - $this->addWithDefaultCheckbox( - $builder, - 'circular_icon_color', - ColorType::class, - [ - 'label' => 'monsieurbiz_better_admin.form.circular_icon_color', - 'help' => 'monsieurbiz_better_admin.form.circular_icon_color_help', - 'required' => false, - ] - ); $this->addWithDefaultCheckbox( $builder, 'logo', @@ -88,21 +70,40 @@ public function buildForm(FormBuilderInterface $builder, array $options): void ); $this->addWithDefaultCheckbox( $builder, - 'custom_css', - TextareaType::class, + 'background_image', + ImageType::class, [ - 'label' => 'monsieurbiz_better_admin.form.custom_css', - 'help' => 'monsieurbiz_better_admin.form.custom_css_help', + 'label' => 'monsieurbiz_better_admin.form.background_image', 'required' => false, ] ); $this->addWithDefaultCheckbox( $builder, - 'background_image_keywords', - TextType::class, + 'color', + ColorType::class, + [ + 'label' => 'monsieurbiz_better_admin.form.color', + 'help' => 'monsieurbiz_better_admin.form.color_help', + 'required' => false, + ] + ); + $this->addWithDefaultCheckbox( + $builder, + 'circular_icon_color', + ColorType::class, [ - 'label' => 'monsieurbiz_better_admin.form.background_image_keywords', - 'help' => 'monsieurbiz_better_admin.form.background_image_keywords_help', + 'label' => 'monsieurbiz_better_admin.form.circular_icon_color', + 'help' => 'monsieurbiz_better_admin.form.circular_icon_color_help', + 'required' => false, + ] + ); + $this->addWithDefaultCheckbox( + $builder, + 'custom_css', + TextareaType::class, + [ + 'label' => 'monsieurbiz_better_admin.form.custom_css', + 'help' => 'monsieurbiz_better_admin.form.custom_css_help', 'required' => false, ] ); diff --git a/src/MonsieurBizSyliusBetterAdminPlugin.php b/src/MonsieurBizSyliusBetterAdminPlugin.php index 25d965e..f6c7a32 100644 --- a/src/MonsieurBizSyliusBetterAdminPlugin.php +++ b/src/MonsieurBizSyliusBetterAdminPlugin.php @@ -1,9 +1,11 @@ - * For the full copyright and license information, please view the LICENSE + * + * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ diff --git a/src/Resources/config/monsieurbiz/settings.yaml b/src/Resources/config/monsieurbiz/settings.yaml index 8f2b8ae..8ff3e9f 100644 --- a/src/Resources/config/monsieurbiz/settings.yaml +++ b/src/Resources/config/monsieurbiz/settings.yaml @@ -13,4 +13,3 @@ monsieurbiz_sylius_settings: circular_icon_color: '#ffffff' logo_login_width: '200' logo_sidebar_width: '90' - background_image_keywords: 'computer,typing,editor' diff --git a/src/Resources/config/sylius/images.yaml b/src/Resources/config/sylius/images.yaml index b7d1509..f9ba741 100644 --- a/src/Resources/config/sylius/images.yaml +++ b/src/Resources/config/sylius/images.yaml @@ -8,3 +8,7 @@ liip_imagine: filters: relative_resize: widen: 250 + admin_login_background: + filters: + relative_resize: + widen: 1600 diff --git a/src/Resources/translations/messages.en.yaml b/src/Resources/translations/messages.en.yaml index 8fffaad..7de754b 100644 --- a/src/Resources/translations/messages.en.yaml +++ b/src/Resources/translations/messages.en.yaml @@ -14,8 +14,7 @@ monsieurbiz_better_admin: logo_sidebar_help: 'Displayed in sidebar (in dark background)' logo_sidebar_width: 'Logo width in sidebar' logo_sidebar_width_help: 'Width of the logo in the sidebar in pixels' - background_image_keywords: 'Background image keywords in login page' - background_image_keywords_help: 'Keywords to search a background image in Unsplash' + background_image: 'Background image of the login page' settings: admin: plugin_name: Admin diff --git a/src/Resources/translations/messages.fr.yaml b/src/Resources/translations/messages.fr.yaml index 74f533b..f75f13d 100644 --- a/src/Resources/translations/messages.fr.yaml +++ b/src/Resources/translations/messages.fr.yaml @@ -14,8 +14,7 @@ monsieurbiz_better_admin: logo_sidebar_help: 'Affiché dans la barre latérale (sur fond sombre)' logo_sidebar_width: 'Largeur du logo dans la barre latérale' logo_sidebar_width_help: 'Largeur du logo dans la barre latérale en pixels' - background_image_keywords: 'Mots-clés de l''image de fond dans la page de connexion' - background_image_keywords_help: 'Mots-clés pour rechercher une image de fond dans Unsplash' + background_image: 'Image de fond de la page de connexion' settings: admin: plugin_name: Admin diff --git a/src/Resources/views/MonsieurBizSyliusAdminBetterLoginPlugin/Admin/Login/_javascript.html.twig b/src/Resources/views/MonsieurBizSyliusAdminBetterLoginPlugin/Admin/Login/_javascript.html.twig deleted file mode 100644 index 29a17fc..0000000 --- a/src/Resources/views/MonsieurBizSyliusAdminBetterLoginPlugin/Admin/Login/_javascript.html.twig +++ /dev/null @@ -1,10 +0,0 @@ -{% include '@SyliusUi/_javascripts.html.twig' with {'path': 'bundles/monsieurbizsyliusadminbetterloginplugin/assets/admin/js/mbiz-admin-better-login.js'} %} - -{% set backgroundImageKeywords = setting('monsieurbiz_better_admin.admin', 'background_image_keywords')|default('') %} -{% if backgroundImageKeywords is not empty %} - -{% else %} - -{% endif %} - - diff --git a/src/Resources/views/SyliusUiBundle/Security/_login.html.twig b/src/Resources/views/SyliusUiBundle/Security/_login.html.twig index 5c71bf2..5a1cf8b 100644 --- a/src/Resources/views/SyliusUiBundle/Security/_login.html.twig +++ b/src/Resources/views/SyliusUiBundle/Security/_login.html.twig @@ -3,6 +3,8 @@ {% import '@SyliusUi/Macro/messages.html.twig' as messages %} {% set logo = setting('monsieurbiz_better_admin.admin', 'logo')|default('') %} +{% set backgroundImage = setting('monsieurbiz_better_admin.admin', 'background_image')|default('') %} +
{{ sonata_block_render_event('sylius.admin.login.before_form', {'form': form}) }} @@ -35,3 +37,21 @@ {{ form_end(form, {'render_rest': false}) }}
+ + diff --git a/src/Twig/Extension/ColorExtension.php b/src/Twig/Extension/ColorExtension.php index 20f1eac..765961e 100644 --- a/src/Twig/Extension/ColorExtension.php +++ b/src/Twig/Extension/ColorExtension.php @@ -1,9 +1,11 @@ - * For the full copyright and license information, please view the LICENSE + * + * For the full copyright and license information, please view the LICENSE.txt * file that was distributed with this source code. */ @@ -46,13 +48,13 @@ public function hexToRgb(string $hex): array public function rgbToHex(int $red, int $green, int $blue): string { - return sprintf('#%02x%02x%02x', $red, $green, $blue); + return \sprintf('#%02x%02x%02x', $red, $green, $blue); } public function hexToRgba(string $hex, float $alpha): string { $rgb = $this->hexToRgb($hex); - return sprintf('rgba(%d, %d, %d, %s)', $rgb[0], $rgb[1], $rgb[2], $alpha); + return \sprintf('rgba(%d, %d, %d, %s)', $rgb[0], $rgb[1], $rgb[2], $alpha); } } diff --git a/dist/src/Entity/.gitignore b/tests/Unit/.gitkeep similarity index 100% rename from dist/src/Entity/.gitignore rename to tests/Unit/.gitkeep