Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PoC - Symfony turbo integration #408

Open
wants to merge 15 commits into
base: 0.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"psr-4": {
"App\\Collector\\": "src/Monofony/MetaPack/CoreMeta/.recipe/src/Collector/",
"App\\Context\\": "src/Monofony/MetaPack/CoreMeta/.recipe/src/Context/",
"App\\Controller\\": "src/Monofony/MetaPack/CoreMeta/.recipe/src/Controller/",
"App\\Command\\": "src/Monofony/MetaPack/CoreMeta/.recipe/src/Command/",
"App\\Dashboard\\": "src/Monofony/MetaPack/AdminMeta/.recipe/src/Dashboard/",
"App\\DataFixtures\\": "src/Monofony/MetaPack/CoreMeta/.recipe/src/DataFixtures/",
Expand Down Expand Up @@ -75,18 +76,18 @@
"gesdinet/jwt-refresh-token-bundle": "^1.0",
"lexik/jwt-authentication-bundle": "^2.14",
"liip/imagine-bundle": "^2.2",
"sylius/customer-bundle": "^1.11",
"sylius/ui-bundle": "^1.11",
"sylius/user-bundle": "^1.11",
"nelmio/cors-bundle": "^2.1",
"pagerfanta/pagerfanta": "^3.5",
"phpdocumentor/reflection-docblock": "^5.2",
"sensio/framework-extra-bundle": "^6.2",
"sensiolabs/security-checker": "^6.0",
"sonata-project/block-bundle": "^4.2",
"sylius/customer-bundle": "^1.11",
"sylius/grid-bundle": "^1.11@beta",
"sylius/mailer-bundle": "^1.6",
"sylius/resource-bundle": "^1.9@beta",
"sylius/ui-bundle": "^1.11",
"sylius/user-bundle": "^1.11",
"symfony/asset": "5.4.*",
"symfony/dotenv": "5.4.*",
"symfony/expression-language": "5.4.*",
Expand All @@ -102,6 +103,7 @@
"symfony/serializer": "5.4.*",
"symfony/swiftmailer-bundle": "^3.0",
"symfony/twig-bundle": "5.4.*",
"symfony/ux-turbo": "^2.1",
"symfony/validator": "5.4.*",
"symfony/webpack-encore-bundle": "^1.6",
"twig/extensions": "^1.5",
Expand Down
1 change: 1 addition & 0 deletions config/bundles.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,4 +41,5 @@
Doctrine\Bundle\FixturesBundle\DoctrineFixturesBundle::class => ['all' => true],
Lexik\Bundle\JWTAuthenticationBundle\LexikJWTAuthenticationBundle::class => ['all' => true],
Gesdinet\JWTRefreshTokenBundle\GesdinetJWTRefreshTokenBundle::class => ['all' => true],
Symfony\UX\Turbo\TurboBundle::class => ['all' => true],
];
20 changes: 8 additions & 12 deletions config/packages/webpack_encore.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
webpack_encore:
# The path where Encore is building the assets.
# This should match Encore.setOutputPath() in webpack.config.js.
output_path: '%kernel.project_dir%/public/build'
# If multiple builds are defined (as shown below), you can disable the default build:
# output_path: false
# The path where Encore is building the assets - i.e. Encore.setOutputPath()
output_path: false

# if using Encore.enableIntegrityHashes() specify the crossorigin attribute value (default: false, or use 'anonymous' or 'use-credentials')
# crossorigin: 'anonymous'

# Cache the entrypoints.json (rebuild Symfony's cache when entrypoints.json changes).
# To enable caching for the production environment, creating a webpack_encore.yaml in the config/packages/prod directory with this value set to true
# Available in version 1.2
#cache: false
# Set attributes that will be rendered on all script and link tags
script_attributes:
defer: true
'data-turbo-track': reload
link_attributes:
'data-turbo-track': reload
5 changes: 4 additions & 1 deletion config/services/monofony_core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,7 @@ services:
app_core_bundle:
namespace: App\
resource: '../../src/Monofony/MetaPack/CoreMeta/.recipe/src/*'
exclude: '../../src/Monofony/MetaPack/CoreMeta/.recipe/src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
exclude:
- '../../src/Monofony/MetaPack/CoreMeta/.recipe/src/{DependencyInjection,Entity,Migrations,Tests,Kernel.php}'
- '../../src/Monofony/MetaPack/CoreMeta/.recipe/src/Controller/ResourceController.php'

60 changes: 0 additions & 60 deletions gulpfile.babel.js

This file was deleted.

52 changes: 30 additions & 22 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,32 @@
{
"dependencies": {
"babel-polyfill": "^6.26.0",
"jquery": "^3.4.0",
"lightbox2": "^2.9.0",
"semantic-ui-css": "npm:fomantic-ui-css@^2.7.0"
},
"devDependencies": {
"@symfony/webpack-encore": "^0.32.0",
"core-js": "^3.0.0",
"node-sass": "^4.12.0",
"sass-loader": "^7.0.1",
"upath": "^1.1.0",
"yargs": "^6.4.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
"dependencies": {
"babel-polyfill": "^6.26.0",
"jquery": "^3.4.0",
"lightbox2": "^2.9.0",
"semantic-ui-css": "npm:fomantic-ui-css@^2.7.0"
},
"devDependencies": {
"@hotwired/stimulus": "^3.0.0",
"@hotwired/turbo": "^7.0.1",
"@symfony/stimulus-bridge": "^3.0.0",
"@symfony/ux-turbo": "file:vendor/symfony/ux-turbo/Resources/assets",
"@symfony/webpack-encore": "^1.7.0",
"core-js": "^3.0.0",
"file-loader": "^6.0.0",
"node-sass": "^7.0.1",
"regenerator-runtime": "^0.13.2",
"sass": "^1.49.9",
"sass-loader": "^12.0.0",
"upath": "^2.0.1",
"webpack-notifier": "^1.6.0",
"yargs": "^6.4.0"
},
"license": "UNLICENSED",
"private": true,
"scripts": {
"dev-server": "encore dev-server",
"dev": "encore dev",
"watch": "encore dev --watch",
"build": "encore production --progress"
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php

/*
* This file is part of the Monofony package.
*
* (c) Monofony
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace App\Monofony\Bundle\CoreBundle\DependencyInjection\Compiler;

use App\Controller\ResourceController;
use App\Controller\UserController;
use Sylius\Bundle\ResourceBundle\Controller\ResourceController as SyliusResourceController;
use Sylius\Bundle\UserBundle\Controller\UserController as SyliusUserController;
use Sylius\Component\Resource\Metadata\Metadata;
use Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface;
use Symfony\Component\DependencyInjection\ContainerBuilder;

class ChangeResourceControllerPass implements CompilerPassInterface
{
/**
* {@inheritdoc}
*/
public function process(ContainerBuilder $container)
{ /** @var array<string, array> $resources */
$resources = $container->hasParameter('sylius.resources') ? $container->getParameter('sylius.resources') : [];

foreach ($resources as $alias => $resourceConfig) {
$metadata = Metadata::fromAliasAndConfiguration($alias, $resourceConfig);
$controller = $resourceConfig['classes']['controller'];
$definition = $container->getDefinition($metadata->getServiceId('controller'));

if (SyliusResourceController::class === $controller) {
$definition->setClass(ResourceController::class);
$container->setDefinition($metadata->getServiceId('controller'), $definition);
}

if (SyliusUserController::class === $controller) {
$definition->setClass(UserController::class);
$container->setDefinition($metadata->getServiceId('controller'), $definition);
}
}
}
}
2 changes: 2 additions & 0 deletions src/Monofony/Bundle/CoreBundle/MonofonyCoreBundle.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

namespace Monofony\Bundle\CoreBundle;

use App\Monofony\Bundle\CoreBundle\DependencyInjection\Compiler\ChangeResourceControllerPass;
use Monofony\Bundle\CoreBundle\DependencyInjection\Compiler\ChangeCustomerContextVisibilityPass;
use Monofony\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterDashboardStatisticsPass;
use Monofony\Bundle\CoreBundle\DependencyInjection\Compiler\RegisterDocumentationNormalizersPass;
Expand All @@ -37,5 +38,6 @@ public function build(ContainerBuilder $container): void
$container->addCompilerPass(new RegisterOAuthClientManager());
$container->addCompilerPass(new RegisterObjectManagerAliasPass());
$container->addCompilerPass(new RegisterDocumentationNormalizersPass());
$container->addCompilerPass(new ChangeResourceControllerPass());
}
}
8 changes: 7 additions & 1 deletion src/Monofony/Bundle/CoreBundle/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
"symfony/config": "5.4.*",
"symfony/dependency-injection": "5.4.*",
"symfony/http-foundation": "5.4.*",
"symfony/http-kernel": "5.4.*"
"symfony/http-kernel": "5.4.*",
"sylius/user-bundle": "^1.11"
},
"require-dev": {
"phpstan/phpstan": "^0.12"
Expand All @@ -24,6 +25,11 @@
".recipe/"
]
},
"autoload_dev": {
"psr-4": {
"App\\Controller\\": "../../MetaPack/CoreMeta/.recipe/src/Controller/"
}
},
"config": {
"sort-packages": true
},
Expand Down
24 changes: 2 additions & 22 deletions src/Monofony/MetaPack/AdminMeta/.recipe/assets/backend/js/app.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,4 @@
import 'babel-polyfill';
import './shim-semantic-ui';

import 'sylius/ui/js/app';
import 'sylius/ui/js/sylius-auto-complete';

import './app-date-time-picker';
import './app-images-preview';
import './sylius-compound-form-errors';

import '../scss/main.scss';
// start the Stimulus application
import './bootstrap';

$(document).ready(function () {
$(document).previewUploadedImage('#sylius_admin_user_avatar');
$('.sylius-autocomplete').autoComplete();
$('.sylius-tabular-form').addTabErrors();
$('.ui.accordion').addAccordionErrors();
$('#sylius_customer_createUser').change(function () {
$('#user-form').toggle();
});

$('.app-date-picker').datePicker();
$('.app-date-time-picker').dateTimePicker();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { startStimulusApp } from '@symfony/stimulus-bridge';

// Registers Stimulus controllers from controllers.json and in the controllers/ directory
export const app = startStimulusApp(require.context(
`@symfony/stimulus-bridge/lazy-controller-loader!./controllers`,
true,
/\.[jt]sx?$/
));

// register any custom, 3rd party controllers here
// app.register('some_controller_name', SomeImportedController);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"controllers": {
"@symfony/ux-turbo": {
"turbo-core": {
"enabled": true,
"loading": "eager"
}
}
},
"entrypoints": []
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import {Controller} from '@hotwired/stimulus';
import 'babel-polyfill';
import 'sylius/ui/js/sylius-auto-complete';

import '../shim-semantic-ui';
import '../app-date-time-picker';
import '../app-images-preview';
import '../sylius-compound-form-errors';
import loadComponents from '../sylius-app';

export default class extends Controller {
connect() {
loadComponents();
$(document).previewUploadedImage('#sylius_admin_user_avatar');
$('.sylius-autocomplete').autoComplete();
$('.sylius-tabular-form').addTabErrors();
$('.ui.accordion').addAccordionErrors();
$('#sylius_customer_createUser').change(function () {
$('#user-form').toggle();
});

$('.app-date-picker').datePicker();
$('.app-date-time-picker').dateTimePicker();
$('.ui.checkbox').checkbox();
}
}
Loading