Skip to content

Commit

Permalink
Merge pull request #2 from lanfisis/master
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran authored Nov 28, 2024
2 parents 46b6a7a + 3549ebc commit 43b53ea
Show file tree
Hide file tree
Showing 8 changed files with 88 additions and 60 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
fail-fast: false
matrix:
php: ['8.2']
sylius: ["~1.12.0"]
sylius: ["~1.12.0", "~1.13.0"]

steps:
- name: Setup PHP
Expand Down
7 changes: 3 additions & 4 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@ 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
echo "${{ matrix.php }}" > .php-version
- name: Determine composer cache directory
id: composer-cache-directory
Expand All @@ -40,8 +39,9 @@ jobs:
id: cache-composer
with:
path: ${{ steps.composer-cache-directory.outputs.directory }}
key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-

- name: Ensure that composer cache directory exists
run: mkdir -p ${{ steps.composer-cache-directory.outputs.directory }}

Expand All @@ -52,4 +52,3 @@ jobs:
run: composer update --prefer-dist

- uses: symfonycorp/security-checker-action@v4

9 changes: 5 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ jobs:

php:

name: Quality tests (PHP ${{ matrix.php }})

runs-on: ubuntu-latest

strategy:
Expand All @@ -19,6 +17,7 @@ jobs:
php: ['8.2']

env:
SYMFONY_ARGS: --no-tls
COMPOSER_ARGS: --prefer-dist
DOCKER_INTERACTIVE_ARGS: -t

Expand All @@ -39,7 +38,7 @@ jobs:

- name: Set project php-version
run: |
echo ${{ matrix.php }} > .php-version
echo "${{ matrix.php }}" > .php-version
- name: Determine composer cache directory
id: composer-cache-directory
Expand All @@ -50,7 +49,7 @@ jobs:
id: cache-composer
with:
path: ${{ steps.composer-cache-directory.outputs.directory }}
key: composer2-php:${{ matrix.php }}-${{ hashFiles('**/composer.json') }}
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-

- name: Ensure that composer cache directory exists
Expand All @@ -69,6 +68,8 @@ jobs:

- run: make test.phpmd

- run: make test.phpspec

- run: make test.yaml

- run: make test.twig
Expand Down
11 changes: 8 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +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=sylius_cms_block_plugin
PLUGIN_NAME=sylius-cms-block-plugin
COMPOSE=docker-compose
COMPOSE=docker compose
YARN=yarn
DOCTRINE_MIGRATIONS_NAMESPACE=MonsieurBiz\SyliusCmsBlockPlugin\Migrations

Expand Down Expand Up @@ -86,6 +86,8 @@ setup_application:
${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

Expand All @@ -110,7 +112,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.phpspec test.phpcs test.yaml test.schema test.twig test.container ## Run all tests in once

test.composer: ## Validate composer.json
${COMPOSER} validate --strict
Expand All @@ -121,6 +123,9 @@ test.phpstan: ## Run PHPStan
test.phpmd: ## Run PHPMD
${COMPOSER} phpmd

test.phpspec: ## Run PHPSpec
${COMPOSER} phpspec

test.phpcs: ## Run PHP CS Fixer in dry-run
${COMPOSER} run -- phpcs --dry-run -v

Expand Down
66 changes: 56 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,58 @@
# Sylius Cms Block Plugin
<h1 align="center">Sylius Cms Block Plugin</h1>

[![Tests Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusCmsBlockPlugin/tests.yaml?branch=master&logo=github)](https://github.com/monsieurbiz/SyliusCmsBlockPlugin/actions?query=workflow%3ATests)
[![Recipe Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusCmsBlockPlugin/recipe.yaml?branch=master&label=recipes&logo=github)](https://github.com/monsieurbiz/SyliusCmsBlockPlugin/actions?query=workflow%3ASecurity)
[![Security Status](https://img.shields.io/github/actions/workflow/status/monsieurbiz/SyliusCmsBlockPlugin/security.yaml?branch=master&label=security&logo=github)](https://github.com/monsieurbiz/SyliusCmsBlockPlugin/actions?query=workflow%3ASecurity)

## Compatibility

| Sylius Version | PHP Version |
|---|-------------|
| 1.12 | 8.2 |
| 1.13 | 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-cms-block-plugin
```
Change your `config/bundles.php` file to add the line for the plugin :
```php
<?php
return [
//..
MonsieurBiz\SyliusCmsBlockPlugin\MonsieurBizSyliusCmsBlockPlugin::class => ['all' => true],
];
```
Then create the config file in `config/packages/monsieurbiz_sylius_cms_block_plugin.yaml` :
```yaml
imports:
resource: '@MonsieurBizSyliusCmsBlockPlugin/Resources/config/config.yaml'
```
Finally import the routes in `config/routes/monsieurbiz_sylius_cms_block_plugin.yaml` :
```yaml
imports:
resource: '@MonsieurBizSyliusCmsBlockPlugin/Resources/config/routes.yaml'
```
### Migrations
First, please run legacy-versioned migrations by using command :
```bash
bin/console doctrine:migrations:migrate
```
After migration, please create a new diff migration :
```php
bin/console doctrine:migrations:diff
```
Then run it (if any) :
```php
bin/console doctrine:migrations:migrate
```

## Example

Expand All @@ -16,7 +70,7 @@ Manage the content of your block, you can decide to disable or enable it to disp

### Include it in your content

For example in your [Homepage](https://github.com/monsieurbiz/SyliusHomepagePlugin) ou [CMS Page](https://github.com/monsieurbiz/SyliusCmsPagePlugin/) !
For example in your [Homepage](https://github.com/monsieurbiz/SyliusHomepagePlugin) ou [CMS Page](https://github.com/monsieurbiz/SyliusCmsBlockPlugin/) !

![Block included in a homepage content](images/block-included.jpg)

Expand All @@ -36,14 +90,6 @@ You can use it in multiple places, it will shown the same content everywhere.

If you disable the block, it will not be displayed anymore.

## Installation

Run the recipe and run migrations

```
console doctrine:migrations:migrate -n
```

## License

This plugin is under the MIT license.
Expand Down
45 changes: 11 additions & 34 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,42 +5,19 @@
"description": "Save rich editor contents in database and use it as UI Element",
"license": "MIT",
"require": {
"monsieurbiz/sylius-rich-editor-plugin": "^2.0",
"monsieurbiz/sylius-rich-editor-plugin": "^2.8",
"php": "^8.2",
"sylius/sylius": ">=1.12 <1.13"
"sylius/sylius": ">=1.12 <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": {
Expand All @@ -63,8 +40,8 @@
"symfony": {
"docker": false,
"endpoint": [
"https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master",
"flex://defaults"
"https://api.github.com/repos/monsieurbiz/symfony-recipes/contents/index.json?ref=flex/master",
"flex://defaults"
]
},
"branch-alias": {
Expand Down
6 changes: 3 additions & 3 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ parameters:
paths:
- %rootDir%/src/

checkMissingIterableValueType: false
checkGenericClassInNonGenericObjectType: false

excludePaths:
# Makes PHPStan crash
- 'src/DependencyInjection/SyliusCmsBlockExtension.php'

# Test dependencies
- 'tests/Application/**/*'

ignoreErrors:
- identifier: missingType.iterableValue
2 changes: 1 addition & 1 deletion src/Form/Type/UiElement/BlockType.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
},
'class' => Block::class,
'multiple' => false,
'choice_label' => fn (BlockInterface $block): string => sprintf('[%s] %s', $block->getCode(), $block->getName()),
'choice_label' => fn (BlockInterface $block): string => \sprintf('[%s] %s', $block->getCode(), $block->getName()),
'query_builder' => function (BlockRepository $blockRepository) {
return $blockRepository->createListQueryBuilder($this->localeContext->getLocaleCode())
->addOrderBy('o.code', 'ASC')
Expand Down

0 comments on commit 43b53ea

Please sign in to comment.