Skip to content

Commit

Permalink
Merge pull request #20 from maximehuran/feature/update-requirements
Browse files Browse the repository at this point in the history
Update Requirements
  • Loading branch information
maximehuran authored Mar 12, 2021
2 parents a81af1c + f58e618 commit cc35fd7
Show file tree
Hide file tree
Showing 85 changed files with 839 additions and 1,179 deletions.
11 changes: 6 additions & 5 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 Down
8 changes: 4 additions & 4 deletions .github/workflows/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,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 Down
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=cms-page
DOCTRINE_NAMESPACE=MonsieurBiz\SyliusCmsPagePlugin\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
18 changes: 10 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,8 @@
"require": {
"php": "~7.4",
"sylius/sylius": "^1.8",
"gedmo/doctrine-extensions": "^2.4.12",
"monsieurbiz/sylius-rich-editor-plugin": "^2.0@RC",
"phpstan/phpstan-webmozart-assert": "^0.12.7"
"gedmo/doctrine-extensions": "^2.4.12 || ^3.0",
"monsieurbiz/sylius-rich-editor-plugin": "^2.0@RC"
},
"require-dev": {
"behat/behat": "^3.6.1",
Expand Down Expand Up @@ -41,10 +40,12 @@
"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"
}
}
2 changes: 1 addition & 1 deletion src/Controller/Admin/Page/PageSlugController.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function __construct(SlugGeneratorInterface $slugGenerator)
*/
public function generateAction(Request $request): JsonResponse
{
$name = $request->query->get('title');
$name = (string) $request->query->get('title');

return new JsonResponse([
'slug' => $this->slugGenerator->generate($name),
Expand Down
3 changes: 1 addition & 2 deletions src/Fixture/Factory/PageFixtureFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
use MonsieurBiz\SyliusCmsPagePlugin\Entity\PageInterface;
use MonsieurBiz\SyliusCmsPagePlugin\Entity\PageTranslationInterface;
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;
Expand All @@ -26,7 +25,7 @@
use Symfony\Component\OptionsResolver\Options;
use Symfony\Component\OptionsResolver\OptionsResolver;

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

/*
* This file is part of Monsieur Biz' Cms Page 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\SyliusCmsPagePlugin\Fixture\Factory;

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

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

namespace MonsieurBiz\SyliusCmsPagePlugin\Fixture;

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

class PageFixture extends AbstractResourceFixture
{
/**
* @param EntityManagerInterface $pageManager
* @param PageFixtureFactoryInterface $exampleFactory
*/
public function __construct(EntityManagerInterface $pageManager, PageFixtureFactoryInterface $exampleFactory)
{
parent::__construct($pageManager, $exampleFactory);
}

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

/*
* This file is part of Monsieur Biz' Cms Page 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\SyliusCmsPagePlugin\Migrations;

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

/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20210311101300 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_cms_page (id INT AUTO_INCREMENT NOT NULL, code VARCHAR(255) NOT NULL, enabled TINYINT(1) DEFAULT \'1\' 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_cms_page_channels (page_id INT NOT NULL, channel_id INT NOT NULL, INDEX IDX_C7095B0AC4663E4 (page_id), INDEX IDX_C7095B0A72F5A1AA (channel_id), PRIMARY KEY(page_id, channel_id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('CREATE TABLE monsieurbiz_cms_page_translation (id INT AUTO_INCREMENT NOT NULL, translatable_id INT NOT NULL, title VARCHAR(255) DEFAULT NULL, content LONGTEXT DEFAULT NULL, slug VARCHAR(255) DEFAULT NULL, metaTitle VARCHAR(255) DEFAULT NULL, metaKeywords VARCHAR(255) DEFAULT NULL, metaDescription LONGTEXT DEFAULT NULL, locale VARCHAR(255) NOT NULL, INDEX IDX_2E2C3B072C2AC5D3 (translatable_id), UNIQUE INDEX monsieurbiz_cms_page_translation_uniq_trans (translatable_id, locale), PRIMARY KEY(id)) DEFAULT CHARACTER SET utf8mb4 COLLATE `utf8mb4_unicode_ci` ENGINE = InnoDB');
$this->addSql('ALTER TABLE monsieurbiz_cms_page_channels ADD CONSTRAINT FK_C7095B0AC4663E4 FOREIGN KEY (page_id) REFERENCES monsieurbiz_cms_page (id)');
$this->addSql('ALTER TABLE monsieurbiz_cms_page_channels ADD CONSTRAINT FK_C7095B0A72F5A1AA FOREIGN KEY (channel_id) REFERENCES sylius_channel (id)');
$this->addSql('ALTER TABLE monsieurbiz_cms_page_translation ADD CONSTRAINT FK_2E2C3B072C2AC5D3 FOREIGN KEY (translatable_id) REFERENCES monsieurbiz_cms_page (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_cms_page_channels DROP FOREIGN KEY FK_C7095B0AC4663E4');
$this->addSql('ALTER TABLE monsieurbiz_cms_page_translation DROP FOREIGN KEY FK_2E2C3B072C2AC5D3');
$this->addSql('DROP TABLE monsieurbiz_cms_page');
$this->addSql('DROP TABLE monsieurbiz_cms_page_channels');
$this->addSql('DROP TABLE monsieurbiz_cms_page_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\SyliusCmsPagePlugin\Migrations': "@MonsieurBizSyliusCmsPagePlugin/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/resources.yaml" }
- { resource: "sylius/grid.yaml" }
- { resource: "sylius/fixtures.yaml" }
2 changes: 1 addition & 1 deletion src/Resources/config/routing/admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ monsieurbiz_sylius_cms_page_admin:
resource: |
alias: monsieurbiz_cms_page.page
section: admin
templates: SyliusAdminBundle:Crud
templates: "@SyliusAdmin\\Crud"
except: ['show']
redirect: update
grid: monsieurbiz_cms_page
Expand Down
5 changes: 0 additions & 5 deletions src/Resources/config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,6 @@ services:
$dataClass: '%monsieurbiz_cms_page.model.page_translation.class%'
$validationGroups: ['monsieurbiz']

# Fixtures
MonsieurBiz\SyliusCmsPagePlugin\Fixture\PageFixture:
arguments:
$exampleFactory: '@MonsieurBiz\SyliusCmsPagePlugin\Fixture\Factory\PageFixtureFactory'

# Routing Context
MonsieurBiz\SyliusCmsPagePlugin\Routing\RequestContext:
decorates: router.request_context
Expand Down
2 changes: 1 addition & 1 deletion src/Resources/config/sylius/grid.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sylius_grid:
label: monsieurbiz_cms_page.ui.form.enabled
sortable: ~
options:
template: SyliusUiBundle:Grid/Field:enabled.html.twig
template: "@SyliusUi/Grid/Field/enabled.html.twig"
actions:
main:
create:
Expand Down
10 changes: 9 additions & 1 deletion src/Resources/views/Admin/Page/_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 cc35fd7

Please sign in to comment.