Skip to content

Commit

Permalink
OP-549: Basic Sylius 2 configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
jkindly committed Oct 11, 2024
1 parent bb5343c commit 63e47d5
Show file tree
Hide file tree
Showing 28 changed files with 115 additions and 128 deletions.
16 changes: 13 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,21 @@
"description": "CMS plugin for Sylius applications.",
"license": "MIT",
"require": {
"php": "^8.1",
"sylius/sylius": "^1.12.0 || ^1.13.0",
"php": "^8.2",
"sylius/grid-bundle": "^1.13@alpha",
"sylius/sylius": "~v2.0.0-alpha.2",
"sylius/twig-hooks": "^0.3.0",
"symfony/ux-autocomplete": "^2.20",
"symfony/ux-live-component": "^2.20",
"symfony/ux-twig-component": "^2.20",
"symfony/webpack-encore-bundle": "^2.1",
"symfony/stimulus-bundle": "^2.20",
"league/csv": "^9.1",
"friendsofsymfony/ckeditor-bundle": "^2.0",
"symfony/webpack-encore-bundle": "^1.12"
"sylius/calendar": "^0.5.0",
"willdurand/hateoas-bundle": "^2.5",
"api-platform/core": "^3.4",
"sylius-labs/polyfill-symfony-security": "^1.1"
},
"require-dev": {
"behat/behat": "^3.7",
Expand Down
6 changes: 1 addition & 5 deletions src/Menu/ContentManagementMenuBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,46 +19,42 @@ public function buildMenu(MenuBuilderEvent $menuBuilderEvent): void
$cmsRootMenuItem = $menu
->addChild('sylius_cms')
->setLabel('sylius_cms.ui.cms')
->setLabelAttribute('icon', 'wand')
;

$cmsRootMenuItem
->addChild('collections', [
'route' => 'sylius_cms_admin_collection_index',
])
->setLabel('sylius_cms.ui.collections')
->setLabelAttribute('icon', 'grid layout')
;

$cmsRootMenuItem
->addChild('templates', [
'route' => 'sylius_cms_admin_template_index',
])
->setLabel('sylius_cms.ui.content_templates')
->setLabelAttribute('icon', 'clone')
;

$cmsRootMenuItem
->addChild('pages', [
'route' => 'sylius_cms_admin_page_index',
])
->setLabel('sylius_cms.ui.pages')
->setLabelAttribute('icon', 'sticky note')
;

$cmsRootMenuItem
->addChild('blocks', [
'route' => 'sylius_cms_admin_block_index',
])
->setLabel('sylius_cms.ui.blocks')
->setLabelAttribute('icon', 'block layout')
;

$cmsRootMenuItem
->addChild('media', [
'route' => 'sylius_cms_admin_media_index',
])
->setLabel('sylius_cms.ui.media')
->setLabelAttribute('icon', 'file')
;

$this->menuReorder->reorder($menu, 'sylius_cms', 'marketing');
Expand Down
3 changes: 2 additions & 1 deletion src/Resources/config/config.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
imports:
- { resource: "@SyliusCmsPlugin/Resources/config/twig_hooks/**/*.yaml" }
- { resource: "@SyliusCmsPlugin/Resources/config/fos_ck_editor/fos_ck_editor.yml" }
- { resource: "@SyliusCmsPlugin/Resources/config/grids.yml" }
- { resource: "@SyliusCmsPlugin/Resources/config/services.xml" }
Expand Down Expand Up @@ -47,5 +48,5 @@ sylius_ui:
sylius.admin.layout.javascripts:
blocks:
version_script:
template: "@SyliusCmsPlugin/Asset/_cmsVersionScript.html.twig"
template: "@SyliusCmsPlugin/Assets/_cmsVersionScript.html.twig"
priority: 30
15 changes: 3 additions & 12 deletions src/Resources/config/routing/admin/block.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,13 @@ sylius_cms_admin_block:
resource: |
alias: sylius_cms.block
section: admin
templates: '@SyliusCmsPlugin/CrudUi'
templates: '@SyliusAdmin\\shared\\crud'
except: ['show']
redirect: update
grid: sylius_cms_admin_block
permission: true
vars:
all:
header: sylius_cms.ui.blocks_header
subheader: sylius_cms.ui.blocks_subheader
templates:
form: "@SyliusCmsPlugin/Block/Crud/_form.html.twig"
index:
icon: block layout
route:
parameters:
code: $type
form:
type: Sylius\CmsPlugin\Form\Type\BlockType
type: sylius.resource

sylius_cms_admin_block_preview:
Expand Down
12 changes: 3 additions & 9 deletions src/Resources/config/routing/admin/collection.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ sylius_cms_admin_collection:
resource: |
alias: sylius_cms.collection
section: admin
templates: '@SyliusCmsPlugin/CrudUi'
templates: '@SyliusAdmin\\shared\\crud'
redirect: update
grid: sylius_cms_admin_collection
except: ['show']
permission: true
vars:
all:
header: sylius_cms.ui.collections_header
subheader: sylius_cms.ui.collections_subheader
templates:
form: "@SyliusCmsPlugin/Collection/Crud/_form.html.twig"
index:
icon: grid layout
form:
type: Sylius\CmsPlugin\Form\Type\CollectionType
type: sylius.resource

sylius_cms_admin_ajax_collection_by_name_phrase:
Expand Down
12 changes: 3 additions & 9 deletions src/Resources/config/routing/admin/media.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ sylius_cms_admin_media:
resource: |
alias: sylius_cms.media
section: admin
templates: '@SyliusCmsPlugin/CrudUi'
templates: '@SyliusAdmin\\shared\\crud'
redirect: update
grid: sylius_cms_admin_media
except: ['show']
permission: true
vars:
all:
header: sylius_cms.ui.media_header
subheader: sylius_cms.ui.media_subheader
templates:
form: "@SyliusCmsPlugin/Media/Crud/_form.html.twig"
index:
icon: file
form:
type: Sylius\CmsPlugin\Form\Type\MediaType
type: sylius.resource

sylius_cms_admin_ajax_media_by_name_phrase:
Expand Down
12 changes: 3 additions & 9 deletions src/Resources/config/routing/admin/page.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,13 @@ sylius_cms_admin_page:
resource: |
alias: sylius_cms.page
section: admin
templates: '@SyliusCmsPlugin/CrudUi'
templates: '@SyliusAdmin\\shared\\crud'
redirect: update
grid: sylius_cms_admin_page
except: ['show']
permission: true
vars:
all:
header: sylius_cms.ui.pages_header
subheader: sylius_cms.ui.pages_subheader
templates:
form: "@SyliusCmsPlugin/Page/Crud/_form.html.twig"
index:
icon: sticky note
form:
type: Sylius\CmsPlugin\Form\Type\PageType
type: sylius.resource

sylius_cms_admin_page_preview:
Expand Down
10 changes: 3 additions & 7 deletions src/Resources/config/routing/admin/template.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,13 @@ sylius_cms_admin_template:
resource: |
alias: sylius_cms.template
section: admin
templates: '@SyliusCmsPlugin/CrudUi'
templates: '@SyliusAdmin\\shared\\crud'
except: ['show']
redirect: update
grid: sylius_cms_admin_template
permission: true
vars:
all:
templates:
form: "@SyliusCmsPlugin/ContentTemplate/Crud/_form.html.twig"
index:
icon: block layout
form:
type: Sylius\CmsPlugin\Form\Type\TemplateType
type: sylius.resource

sylius_cms_admin_ajax_template_page_by_name_phrase:
Expand Down
8 changes: 8 additions & 0 deletions src/Resources/config/twig_hooks/base.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
twig_hooks:
hooks:
'sylius_admin.base#stylesheets':
styles:
template: '@SyliusCmsPlugin/Assets/css.html.twig'
'sylius_admin.base#javascripts':
scripts:
template: '@SyliusCmsPlugin/Assets/js.html.twig'
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
<script>
const route = "{{ path('sylius_cms_admin_ajax_media_by_name_phrase')|escape('js') }}";
</script>
{{ encore_entry_script_tags('admin-entry', null, 'admin') }}
{{ encore_entry_script_tags('sylius-cms-admin', null, 'cms_admin') }}
58 changes: 0 additions & 58 deletions src/Resources/views/Page/Crud/_form.html.twig

This file was deleted.

1 change: 0 additions & 1 deletion src/Resources/views/layout.html.twig

This file was deleted.

6 changes: 3 additions & 3 deletions tests/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace Tests\Sylius\CmsPlugin\Application;

use PSS\SymfonyMockerContainer\DependencyInjection\MockerContainer;
use Sylius\Bundle\CoreBundle\Application\Kernel as SyliusKernel;
use Sylius\Bundle\CoreBundle\SyliusCoreBundle;
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait;
use Symfony\Component\Config\Loader\DelegatingLoader;
use Symfony\Component\Config\Loader\LoaderInterface;
Expand Down Expand Up @@ -58,7 +58,7 @@ protected function configureContainer(ContainerBuilder $container, LoaderInterfa
$container->addResource(new FileResource($this->getProjectDir() . '/config/bundles.php'));
$container->setParameter('container.dumper.inline_class_loader', true);
$confDir = $this->getProjectDir() . '/config';
$syliusDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION;
$syliusDir = $this->getProjectDir() . '/config/sylius/' . SyliusCoreBundle::MAJOR_VERSION . '.' . SyliusCoreBundle::MINOR_VERSION;

$loader->load($confDir . '/{packages}/*' . self::CONFIG_EXTS, 'glob');
$loader->load($confDir . '/{packages}/' . $this->environment . '/**/*' . self::CONFIG_EXTS, 'glob');
Expand Down Expand Up @@ -135,7 +135,7 @@ private function registerBundlesFromFile(string $bundlesFile): iterable
private function getConfigurationDirectories(): iterable
{
yield $this->getProjectDir() . '/config';
$syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusKernel::MAJOR_VERSION . '.' . SyliusKernel::MINOR_VERSION;
$syliusConfigDir = $this->getProjectDir() . '/config/sylius/' . SyliusCoreBundle::MAJOR_VERSION . '.' . SyliusCoreBundle::MINOR_VERSION;
if (is_dir($syliusConfigDir)) {
yield $syliusConfigDir;
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Application/assets/admin/entry.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import 'sylius/bundle/AdminBundle/Resources/private/entry';
import 'sylius/bundle/AdminBundle/Resources/assets/entrypoint';
1 change: 1 addition & 0 deletions tests/Application/assets/admin/product-entry.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
import 'sylius/bundle/AdminBundle/Resources/assets/scripts/product/attribute-tabs-refresher';
17 changes: 17 additions & 0 deletions tests/Application/assets/controllers.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"controllers": {
"@symfony/ux-autocomplete": {
"autocomplete": {
"main": "dist/controller.js",
"webpackMode": "eager",
"fetch": "eager",
"enabled": true,
"autoimport": {
"tom-select/dist/css/tom-select.default.css": false,
"tom-select/dist/css/tom-select.bootstrap5.css": false
}
}
}
},
"entrypoints": []
}
2 changes: 1 addition & 1 deletion tests/Application/assets/shop/entry.js
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
import 'sylius/bundle/ShopBundle/Resources/private/entry';
import 'sylius/bundle/ShopBundle/Resources/assets/entrypoint';
import './styles.scss';
7 changes: 6 additions & 1 deletion tests/Application/config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
Fidry\AliceDataFixtures\Bridge\Symfony\FidryAliceDataFixturesBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
Nelmio\Alice\Bridge\Symfony\NelmioAliceBundle::class => ['dev' => true, 'test' => true, 'test_cached' => true],
FriendsOfBehat\SymfonyExtension\Bundle\FriendsOfBehatSymfonyExtensionBundle::class => ['test' => true, 'test_cached' => true],
ApiPlatform\Core\Bridge\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Sylius\Bundle\ApiBundle\SyliusApiBundle::class => ['all' => true],
SyliusLabs\DoctrineMigrationsExtraBundle\SyliusLabsDoctrineMigrationsExtraBundle::class => ['all' => true],
Expand All @@ -62,4 +62,9 @@
Symfony\WebpackEncoreBundle\WebpackEncoreBundle::class => ['all' => true],
FOS\CKEditorBundle\FOSCKEditorBundle::class => ['all' => true],
Sylius\CmsPlugin\SyliusCmsPlugin::class => ['all' => true],
Sylius\TwigHooks\TwigHooksBundle::class => ['all' => true],
Symfony\UX\TwigComponent\TwigComponentBundle::class => ['all' => true],
Symfony\UX\LiveComponent\LiveComponentBundle::class => ['all' => true],
Symfony\UX\Autocomplete\AutocompleteBundle::class => ['all' => true],
Symfony\UX\StimulusBundle\StimulusBundle::class => ['all' => true],
];
1 change: 0 additions & 1 deletion tests/Application/config/packages/security.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
security:
enable_authenticator_manager: true
providers:
sylius_admin_user_provider:
id: sylius.admin_user_provider.email_or_name_based
Expand Down
3 changes: 3 additions & 0 deletions tests/Application/config/routes/ux.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
live_component:
resource: "@LiveComponentBundle/config/routes.php"
prefix: /{_locale}/_components
14 changes: 14 additions & 0 deletions tests/Application/config/sylius/2.0/bundles.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

/*
* This file has been created by developers from BitBag.
* Feel free to contact us once you face any issues or want to start
* You can find more information about us on https://bitbag.io and write us
* an email on [email protected].
*/

declare(strict_types=1);

return [
Sylius\Abstraction\StateMachine\SyliusStateMachineAbstractionBundle::class => ['all' => true],
];
10 changes: 10 additions & 0 deletions tests/Application/config/sylius/2.0/packages/_sylius.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
parameters:
test_default_state_machine_adapter: 'symfony_workflow'
test_sylius_state_machine_adapter: '%env(string:default:test_default_state_machine_adapter:TEST_SYLIUS_STATE_MACHINE_ADAPTER)%'

sylius_state_machine_abstraction:
graphs_to_adapters_mapping:
sylius_refund_refund_payment: '%test_sylius_state_machine_adapter%'

sylius_api:
enabled: true
Loading

0 comments on commit 63e47d5

Please sign in to comment.