Skip to content

Commit

Permalink
Merge pull request #14 from maximehuran/feature/update-requirements
Browse files Browse the repository at this point in the history
Update requirements to be compatible with Sylius 1.9
  • Loading branch information
maximehuran authored Mar 17, 2021
2 parents 9493d54 + 59df2ce commit 62920ed
Show file tree
Hide file tree
Showing 96 changed files with 712 additions and 1,061 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/recipe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ jobs:
fail-fast: false
matrix:
php: [7.4]
sylius: [1.8, 1.9]

steps:
- name: Setup PHP
Expand All @@ -44,21 +45,21 @@ jobs:
id: cache-composer
with:
path: /home/runner/.composer/cache
key: composer-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer-php:${{ matrix.php }}-
key: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-sylius:${{ matrix.sylius }}-

- run: mkdir -p /home/runner/.composer/cache
if: steps.cache-composer.outputs.cache-hit != 'true'

- name: Composer v1
run: sudo composer self-update --1
- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}

- name: Install Sylius-Standard
run: |
composer create-project --prefer-dist --no-scripts --no-progress sylius/sylius-standard sylius
composer create-project --prefer-dist --no-scripts --no-progress sylius/sylius-standard sylius "~${{ matrix.sylius }}.0"
- name: Setup some requirements
working-directory: ./sylius
Expand All @@ -71,7 +72,7 @@ jobs:
- name: Install monsieurbiz/sylius-rich-editor-plugin
working-directory: ./sylius
run: |
composer require monsieurbiz/sylius-rich-editor-plugin="v2.0.0-RC.3" --no-scripts
composer require monsieurbiz/sylius-rich-editor-plugin="^2.0@RC" --no-scripts
sed -i -e "s/];/MonsieurBiz\\\SyliusRichEditorPlugin\\\MonsieurBizSyliusRichEditorPlugin::class => ['all' => true], ];/g" config/bundles.php
cp -Rv vendor/monsieurbiz/sylius-rich-editor-plugin/recipes/2.0-dev/config/* config/
Expand Down
51 changes: 51 additions & 0 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Security

on:
push:
pull_request:
schedule:
- cron: '0 0 * * *'

jobs:

security:

runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
php: [7.4]

steps:
- uses: actions/checkout@v2

- name: Setup PHP
run: |
sudo update-alternatives --set php /usr/bin/php${{ matrix.php }}
echo "date.timezone=UTC" | sudo tee /etc/php/${{ matrix.php }}/cli/conf.d/timezone.ini
echo "${{ matrix.php }}" > .php-version
- uses: actions/cache@v1
id: cache-composer
with:
path: /home/runner/.composer/cache
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-

- run: mkdir -p /home/runner/.composer/cache
if: steps.cache-composer.outputs.cache-hit != 'true'

- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}

- uses: actions/checkout@v2

- name: Install PHP dependencies
run: composer update --prefer-dist

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

9 changes: 5 additions & 4 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ jobs:
id: cache-composer
with:
path: /home/runner/.composer/cache
key: composer-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer-php:${{ matrix.php }}-
key: composer2-php:${{ matrix.php }}-${{ github.sha }}
restore-keys: composer2-php:${{ matrix.php }}-

- run: mkdir -p /home/runner/.composer/cache
if: steps.cache-composer.outputs.cache-hit != 'true'

- name: Composer v1
run: sudo composer self-update --1
- name: Composer v2
run: sudo composer self-update --2

- name: Composer Github Auth
run: composer config -g github-oauth.github.com ${{ github.token }}
Expand All @@ -70,5 +70,6 @@ jobs:
- run: make test.twig

- run: make test.schema
continue-on-error: true # See https://github.com/Sylius/Sylius/pull/12413

#- run: make test.container
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

/tests/Application/yarn.lock
/tests/Application/package-lock.json
/tests/Application/.php-version

/behat.yml
/phpspec.yml
Expand Down
8 changes: 6 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ SYMFONY=cd ${APP_DIR} && symfony
COMPOSER=symfony composer
CONSOLE=${SYMFONY} console
export COMPOSE_PROJECT_NAME=homepage
DOCTRINE_NAMESPACE=MonsieurBiz\SyliusHomepagePlugin\Migrations
COMPOSE=docker-compose
YARN=yarn
PHPUNIT=symfony php vendor/bin/phpunit
Expand Down Expand Up @@ -95,7 +96,7 @@ test.schema: ## Validate MySQL Schema
${CONSOLE} doctrine:schema:validate

test.twig: ## Validate Twig templates
${CONSOLE} lint:twig -e prod --no-debug ../../src/Resources/views/
${CONSOLE} lint:twig --no-debug ../../src/Resources/views/

###
### SYLIUS
Expand All @@ -107,7 +108,7 @@ sylius: dependencies sylius.database sylius.fixtures sylius.assets ## Install Sy
sylius.database: ## Setup the database
${CONSOLE} doctrine:database:drop --if-exists --force
${CONSOLE} doctrine:database:create --if-not-exists
${CONSOLE} doctrine:schema:update --force
${CONSOLE} doctrine:migration:migrate -n

sylius.fixtures: ## Run the fixtures
${CONSOLE} sylius:fixtures:load -n default
Expand All @@ -117,6 +118,9 @@ sylius.assets: ## Install all assets with symlinks
${CONSOLE} sylius:install:assets
${CONSOLE} sylius:theme:assets:install --symlink

doctrine.diff: ## Make doctrine diff
${CONSOLE} doctrine:migration:diff --namespace="${DOCTRINE_NAMESPACE}"

###
### PLATFORM
### ¯¯¯¯¯¯¯¯
Expand Down
16 changes: 9 additions & 7 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"require": {
"php": "~7.4",
"sylius/sylius": "^1.8",
"gedmo/doctrine-extensions": "^2.4.12",
"gedmo/doctrine-extensions": "^2.4.12 || ^3.0",
"monsieurbiz/sylius-rich-editor-plugin": "^2.0@RC"
},
"require-dev": {
Expand All @@ -33,18 +33,19 @@
"phpspec/phpspec": "^6.1",
"phpstan/phpstan": "0.12.29",
"phpstan/phpstan-doctrine": "0.12.16",
"phpstan/phpstan-webmozart-assert": "^0.12.7",
"phpunit/phpunit": "^8.5",
"psalm/plugin-mockery": "^0.3",
"psr/event-dispatcher": "^1.0",
"sspooky13/yaml-standards": "^5.1",
"sylius-labs/coding-standard": "^3.1",
"symfony/browser-kit": "^4.4",
"symfony/debug-bundle": "^4.4",
"symfony/dotenv": "^4.4",
"symfony/dotenv": "^4.4 || ^5.2",
"symfony/flex": "^1.7",
"symfony/web-profiler-bundle": "^4.4",
"phpmd/phpmd": "@stable"
"symfony/web-profiler-bundle": "^4.4 || ^5.2",
"phpmd/phpmd": "@stable",
"phpstan/phpstan-webmozart-assert": "^0.12.7",
"friendsofsymfony/oauth-server-bundle": "^1.6 || >2.0.0-alpha.0 ^2.0@dev"
},
"prefer-stable": true,
"autoload": {
Expand All @@ -62,7 +63,8 @@
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"config-dir": "./tests/Application/config/"
},
"scripts": {
"auto-scripts": {
Expand All @@ -71,6 +73,6 @@
},
"phpcs": "php-cs-fixer fix --using-cache=false",
"phpstan": "phpstan analyse -c phpstan.neon src/",
"phpmd": "phpmd src/ ansi phpmd.xml"
"phpmd": "phpmd --exclude Migrations/* src/ ansi phpmd.xml"
}
}
3 changes: 1 addition & 2 deletions src/Fixture/Factory/HomepageFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,14 @@
use MonsieurBiz\SyliusHomepagePlugin\Entity\HomepageInterface;
use MonsieurBiz\SyliusHomepagePlugin\Entity\HomepageTranslationInterface;
use Sylius\Bundle\CoreBundle\Fixture\Factory\AbstractExampleFactory;
use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;
use Sylius\Bundle\CoreBundle\Fixture\OptionsResolver\LazyOption;
use Sylius\Component\Channel\Repository\ChannelRepositoryInterface;
use Sylius\Component\Locale\Model\LocaleInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;

class HomepageFixtureFactory extends AbstractExampleFactory implements ExampleFactoryInterface
class HomepageFixtureFactory extends AbstractExampleFactory implements HomepageFixtureFactoryInterface
{
/**
* @var FactoryInterface
Expand Down
20 changes: 20 additions & 0 deletions src/Fixture/Factory/HomepageFixtureFactoryInterface.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

/*
* This file is part of Monsieur Biz' Homepage plugin for Sylius.
*
* (c) Monsieur Biz <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace MonsieurBiz\SyliusHomepagePlugin\Fixture\Factory;

use Sylius\Bundle\CoreBundle\Fixture\Factory\ExampleFactoryInterface;

interface HomepageFixtureFactoryInterface extends ExampleFactoryInterface
{
}
11 changes: 11 additions & 0 deletions src/Fixture/HomepageFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,22 @@

namespace MonsieurBiz\SyliusHomepagePlugin\Fixture;

use Doctrine\ORM\EntityManagerInterface;
use MonsieurBiz\SyliusHomepagePlugin\Fixture\Factory\HomepageFixtureFactoryInterface;
use Sylius\Bundle\CoreBundle\Fixture\AbstractResourceFixture;
use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition;

class HomepageFixture extends AbstractResourceFixture
{
/**
* @param EntityManagerInterface $homepageManager
* @param HomepageFixtureFactoryInterface $exampleFactory
*/
public function __construct(EntityManagerInterface $homepageManager, HomepageFixtureFactoryInterface $exampleFactory)
{
parent::__construct($homepageManager, $exampleFactory);
}

/**
* {@inheritdoc}
*/
Expand Down
49 changes: 49 additions & 0 deletions src/Migrations/Version20210311135118.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of Monsieur Biz' Homepage plugin for Sylius.
*
* (c) Monsieur Biz <[email protected]>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace MonsieurBiz\SyliusHomepagePlugin\Migrations;

use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210311135118 extends AbstractMigration
{
public function getDescription(): string
{
return '';
}

public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->addSql('CREATE TABLE monsieurbiz_homepage_homepage (id INT AUTO_INCREMENT NOT NULL, created_at DATETIME NOT NULL COMMENT \'(DC2Type:datetime_immutable)\', updated_at DATETIME NOT NULL, PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE monsieurbiz_homepage_homepage_channels (page_id INT NOT NULL, channel_id INT NOT NULL, INDEX IDX_1BF0DD4EC4663E4 (page_id), UNIQUE INDEX UNIQ_1BF0DD4E72F5A1AA (channel_id), PRIMARY KEY(page_id, channel_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE monsieurbiz_homepage_homepage_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, name VARCHAR(255) DEFAULT NULL, content LONGTEXT DEFAULT NULL, metaTitle VARCHAR(255) DEFAULT NULL, metaKeywords VARCHAR(255) DEFAULT NULL, metaDescription LONGTEXT DEFAULT NULL, locale VARCHAR(255) DEFAULT NULL, INDEX IDX_F0076BB22C2AC5D3 (translatable_id), UNIQUE INDEX monsieurbiz_homepage_homepage_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE monsieurbiz_homepage_homepage_channels ADD CONSTRAINT FK_1BF0DD4EC4663E4 FOREIGN KEY (page_id) REFERENCES monsieurbiz_homepage_homepage (id)');
$this->addSql('ALTER TABLE monsieurbiz_homepage_homepage_channels ADD CONSTRAINT FK_1BF0DD4E72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id)');
$this->addSql('ALTER TABLE monsieurbiz_homepage_homepage_translation ADD CONSTRAINT FK_F0076BB22C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES monsieurbiz_homepage_homepage (id) ON DELETE CASCADE');
}

public function down(Schema $schema): void
{
// this down() migration is auto-generated, please modify it to your needs
$this->addSql('ALTER TABLE monsieurbiz_homepage_homepage_channels DROP FOREIGN KEY FK_1BF0DD4EC4663E4');
$this->addSql('ALTER TABLE monsieurbiz_homepage_homepage_translation DROP FOREIGN KEY FK_F0076BB22C2AC5D3');
$this->addSql('DROP TABLE monsieurbiz_homepage_homepage');
$this->addSql('DROP TABLE monsieurbiz_homepage_homepage_channels');
$this->addSql('DROP TABLE monsieurbiz_homepage_homepage_translation');
}
}
3 changes: 3 additions & 0 deletions src/Resources/config/app/doctrine_migrations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
doctrine_migrations:
migrations_paths:
'MonsieurBiz\SyliusHomepagePlugin\Migrations': "@MonsieurBizSyliusHomepagePlugin/Migrations"
1 change: 1 addition & 0 deletions src/Resources/config/config.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
imports:
- { resource: 'app/doctrine_migrations.yaml' }
- { resource: "sylius/fixtures.yaml" }
- { resource: "sylius/grid.yaml" }
- { resource: "sylius/resources.yaml" }
5 changes: 0 additions & 5 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,3 @@ services:
$dataClass: '%monsieurbiz_homepage.model.homepage_translation.class%'
$validationGroups: ['monsieurbiz']

# Fixtures
MonsieurBiz\SyliusHomepagePlugin\Fixture\HomepageFixture:
arguments:
$exampleFactory: '@MonsieurBiz\SyliusHomepagePlugin\Fixture\Factory\HomepageFixtureFactory'

10 changes: 9 additions & 1 deletion src/Resources/views/Admin/Homepage/_form.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,15 @@
</h4>
<div class="ui segment">
{{ form_errors(form) }}
{{ form_rest(form) }}
{# Issue with Symfony 5, Sylius 1.9 : https://github.com/Sylius/Sylius/pull/12439 #}
{# So we render the fields #}
{% for item in form.children %}
{% if item.vars.name != '_token' %}
{{ form_row(item) }}
{% endif %}
{% endfor %}
{# Instead of #}
{# {{ form_rest(form) }} #}
</div>
<h4 class="ui horizontal divider header">
<i class="flag icon"></i>
Expand Down
Loading

0 comments on commit 62920ed

Please sign in to comment.