From 90f226e0058c43685573832151fcc83b40892716 Mon Sep 17 00:00:00 2001 From: Arty Date: Mon, 12 Feb 2024 18:30:55 +0100 Subject: [PATCH] Update config with PHP files --- composer.lock | 2 +- config/packages/cache.php | 9 +++ config/packages/cache.yaml | 19 ----- config/packages/doctrine.php | 78 +++++++++++++++++++ config/packages/doctrine.yaml | 62 --------------- config/packages/doctrine_migrations.php | 10 +++ config/packages/doctrine_migrations.yaml | 6 -- config/packages/framework.php | 22 ++++++ config/packages/framework.yaml | 26 ------- config/packages/lexik_jwt_authentication.php | 13 ++++ config/packages/lexik_jwt_authentication.yaml | 6 -- config/packages/mercure.php | 26 +++++++ config/packages/mercure.yaml | 18 ----- config/packages/monolog.php | 67 ++++++++++++++++ config/packages/monolog.yaml | 61 --------------- config/packages/nelmio_cors.php | 16 ++++ config/packages/nelmio_cors.yaml | 9 --- config/packages/routing.php | 18 +++++ config/packages/routing.yaml | 12 --- config/packages/security.php | 37 +++++++++ config/packages/security.yaml | 43 ---------- config/packages/twig.php | 14 ++++ config/packages/twig.yaml | 3 - config/packages/validator.php | 18 +++++ config/packages/validator.yaml | 13 ---- config/packages/web_profiler.php | 32 ++++++++ config/packages/web_profiler.yaml | 17 ---- config/packages/workflow.php | 33 ++++++++ config/packages/workflow.yaml | 22 ------ 29 files changed, 394 insertions(+), 318 deletions(-) create mode 100644 config/packages/cache.php delete mode 100644 config/packages/cache.yaml create mode 100644 config/packages/doctrine.php delete mode 100644 config/packages/doctrine.yaml create mode 100644 config/packages/doctrine_migrations.php delete mode 100644 config/packages/doctrine_migrations.yaml create mode 100644 config/packages/framework.php delete mode 100644 config/packages/framework.yaml create mode 100644 config/packages/lexik_jwt_authentication.php delete mode 100644 config/packages/lexik_jwt_authentication.yaml create mode 100644 config/packages/mercure.php delete mode 100644 config/packages/mercure.yaml create mode 100644 config/packages/monolog.php delete mode 100644 config/packages/monolog.yaml create mode 100644 config/packages/nelmio_cors.php delete mode 100644 config/packages/nelmio_cors.yaml create mode 100644 config/packages/routing.php delete mode 100644 config/packages/routing.yaml create mode 100644 config/packages/security.php delete mode 100644 config/packages/security.yaml create mode 100644 config/packages/twig.php delete mode 100644 config/packages/twig.yaml create mode 100644 config/packages/validator.php delete mode 100644 config/packages/validator.yaml create mode 100644 config/packages/web_profiler.php delete mode 100644 config/packages/web_profiler.yaml create mode 100644 config/packages/workflow.php delete mode 100644 config/packages/workflow.yaml diff --git a/composer.lock b/composer.lock index 3f532f9..3cd4860 100644 --- a/composer.lock +++ b/composer.lock @@ -12388,5 +12388,5 @@ "ext-apcu": "*" }, "platform-dev": [], - "plugin-api-version": "2.2.0" + "plugin-api-version": "2.6.0" } diff --git a/config/packages/cache.php b/config/packages/cache.php new file mode 100644 index 0000000..8815cc9 --- /dev/null +++ b/config/packages/cache.php @@ -0,0 +1,9 @@ +cache()->app('cache.adapter.apcu'); +}; diff --git a/config/packages/cache.yaml b/config/packages/cache.yaml deleted file mode 100644 index 68ab09f..0000000 --- a/config/packages/cache.yaml +++ /dev/null @@ -1,19 +0,0 @@ -framework: - cache: - # Unique name of your app: used to compute stable namespaces for cache keys. - #prefix_seed: your_vendor_name/app_name - - # The "app" cache stores to the filesystem by default. - # The data in this cache should persist between deploys. - # Other options include: - - # Redis - #app: cache.adapter.redis - #default_redis_provider: redis://localhost - - # APCu (not recommended with heavy random-write workloads as memory fragmentation can cause perf issues) - app: cache.adapter.apcu - - # Namespaced pools use the above "app" backend by default - #pools: - #my.dedicated.cache: null diff --git a/config/packages/doctrine.php b/config/packages/doctrine.php new file mode 100644 index 0000000..b54a277 --- /dev/null +++ b/config/packages/doctrine.php @@ -0,0 +1,78 @@ +dbal()->defaultConnection('default'); + $dbalConfig = $doctrineConfig->dbal()->connection('default'); + + $dbalConfig + ->url('%env(resolve:DATABASE_URL)%') + ->profilingCollectBacktrace('%kernel.debug%'); + + $doctrineConfig->orm()->defaultEntityManager('default'); + $entityManagerConfig = $doctrineConfig->orm() + ->autoGenerateProxyClasses(true) + ->enableLazyGhostObjects(true) + ->entityManager('default'); + + $entityManagerConfig + ->reportFieldsWhereDeclared(true) + ->validateXmlMapping(true) + ->namingStrategy('doctrine.orm.naming_strategy.underscore_number_aware') + ->autoMapping(true); + + $entityManagerConfig->mapping(Room::class) + ->type('attribute') + ->isBundle(false) + ->dir('%kernel.project_dir%/src/Domain/Room/Entity') + ->prefix('App\Domain\Room\Entity') + ->alias('App\Domain\Room'); + + $entityManagerConfig->mapping(Player::class) + ->type('attribute') + ->isBundle(false) + ->dir('%kernel.project_dir%/src/Domain/Player/Entity') + ->prefix('App\Domain\Player\Entity') + ->alias('App\Domain\Player'); + + $entityManagerConfig->mapping(Mission::class) + ->type('attribute') + ->isBundle(false) + ->dir('%kernel.project_dir%/src/Domain/Mission/Entity') + ->prefix('App\Domain\Mission\Entity') + ->alias('App\Domain\Mission'); + + if ($containerConfigurator->env() === 'test') { + $dbalConfig->url('%env(resolve:DATABASE_URL_TEST)%'); + } + + if ($containerConfigurator->env() !== 'prod') { + return; + } + + $doctrineConfig->orm() + ->autoGenerateProxyClasses(false) + ->proxyDir('%kernel.build_dir%/doctrine/orm/Proxies'); + + $entityManagerConfig->queryCacheDriver() + ->type('pool') + ->pool('doctrine.system_cache_pool'); + $entityManagerConfig->resultCacheDriver() + ->type('pool') + ->pool('doctrine.result_cache_pool'); + + $frameworkConfig->cache()->pool('doctrine.result_cache_pool')->adapters(['cache.app']); + $frameworkConfig->cache()->pool('doctrine.system_cache_pool')->adapters(['cache.system']); +}; diff --git a/config/packages/doctrine.yaml b/config/packages/doctrine.yaml deleted file mode 100644 index 79f8f7b..0000000 --- a/config/packages/doctrine.yaml +++ /dev/null @@ -1,62 +0,0 @@ -doctrine: - dbal: - url: '%env(resolve:DATABASE_URL)%' - - # IMPORTANT: You MUST configure your server version, - # either here or in the DATABASE_URL env var (see .env file) - #server_version: '15' - - profiling_collect_backtrace: '%kernel.debug%' - orm: - auto_generate_proxy_classes: true - enable_lazy_ghost_objects: true - report_fields_where_declared: true - validate_xml_mapping: true - naming_strategy: doctrine.orm.naming_strategy.underscore_number_aware - auto_mapping: true - mappings: - App\Domain\Room\Entity\Room: - type: attribute - is_bundle: false - dir: '%kernel.project_dir%/src/Domain/Room/Entity' - prefix: 'App\Domain\Room\Entity' - alias: App\Domain\Room - App\Domain\Player\Entity\Player: - type: attribute - is_bundle: false - dir: '%kernel.project_dir%/src/Domain/Player/Entity' - prefix: 'App\Domain\Player\Entity' - alias: App\Domain\Player - App\Domain\Mission\Entity\Mission: - type: attribute - is_bundle: false - dir: '%kernel.project_dir%/src/Domain/Mission/Entity' - prefix: 'App\Domain\Mission\Entity' - alias: App\Domain\Mission - -when@test: - doctrine: - dbal: - url: '%env(resolve:DATABASE_URL_TEST)%' - # "TEST_TOKEN" is typically set by ParaTest -# dbname_suffix: '_test%env(default::TEST_TOKEN)%' - -when@prod: - doctrine: - orm: - auto_generate_proxy_classes: false - proxy_dir: '%kernel.build_dir%/doctrine/orm/Proxies' - query_cache_driver: - type: pool - pool: doctrine.system_cache_pool - result_cache_driver: - type: pool - pool: doctrine.result_cache_pool - - framework: - cache: - pools: - doctrine.result_cache_pool: - adapter: cache.app - doctrine.system_cache_pool: - adapter: cache.system diff --git a/config/packages/doctrine_migrations.php b/config/packages/doctrine_migrations.php new file mode 100644 index 0000000..8cb9e5f --- /dev/null +++ b/config/packages/doctrine_migrations.php @@ -0,0 +1,10 @@ +migrationsPath('DoctrineMigrations', '%kernel.project_dir%/migrations'); + $doctrineMigrationsConfig->enableProfiler(false); +}; diff --git a/config/packages/doctrine_migrations.yaml b/config/packages/doctrine_migrations.yaml deleted file mode 100644 index 29231d9..0000000 --- a/config/packages/doctrine_migrations.yaml +++ /dev/null @@ -1,6 +0,0 @@ -doctrine_migrations: - migrations_paths: - # namespace is arbitrary but should be different from App\Migrations - # as migrations classes should NOT be autoloaded - 'DoctrineMigrations': '%kernel.project_dir%/migrations' - enable_profiler: false diff --git a/config/packages/framework.php b/config/packages/framework.php new file mode 100644 index 0000000..4cecf82 --- /dev/null +++ b/config/packages/framework.php @@ -0,0 +1,22 @@ +secret('%env(APP_SECRET)%'); + $frameworkConfig->csrfProtection()->enabled(false); + $frameworkConfig->annotations()->enabled(false); + $frameworkConfig->httpMethodOverride(false); + $frameworkConfig->handleAllThrowables(true); + $frameworkConfig->session()->enabled(false); + $frameworkConfig->phpErrors()->log(true); + + if ($containerConfigurator->env() !== 'test') { + return; + } + + $frameworkConfig->test(true); +}; diff --git a/config/packages/framework.yaml b/config/packages/framework.yaml deleted file mode 100644 index ee20759..0000000 --- a/config/packages/framework.yaml +++ /dev/null @@ -1,26 +0,0 @@ -# see https://symfony.com/doc/current/reference/configuration/framework.html -framework: - secret: '%env(APP_SECRET)%' - csrf_protection: false - annotations: false - http_method_override: false - handle_all_throwables: true - - # Enables session support. Note that the session will ONLY be started if you read or write from it. - # Remove or comment this section to explicitly disable session support. - session: - handler_id: session.handler.native_file - save_path: '%kernel.project_dir%/var/sessions/%kernel.environment%' - cookie_secure: auto - cookie_samesite: lax - - #esi: true - #fragments: true - php_errors: - log: true - -when@test: - framework: - test: true - session: - storage_factory_id: session.storage.factory.mock_file diff --git a/config/packages/lexik_jwt_authentication.php b/config/packages/lexik_jwt_authentication.php new file mode 100644 index 0000000..c300000 --- /dev/null +++ b/config/packages/lexik_jwt_authentication.php @@ -0,0 +1,13 @@ +secretKey('%env(resolve:JWT_SECRET_KEY)%') + ->publicKey('%env(resolve:JWT_PUBLIC_KEY)%') + ->passPhrase('%env(JWT_PASSPHRASE)%') + ->tokenTtl(2628288); +}; diff --git a/config/packages/lexik_jwt_authentication.yaml b/config/packages/lexik_jwt_authentication.yaml deleted file mode 100644 index f701b56..0000000 --- a/config/packages/lexik_jwt_authentication.yaml +++ /dev/null @@ -1,6 +0,0 @@ -lexik_jwt_authentication: - secret_key: '%env(resolve:JWT_SECRET_KEY)%' - public_key: '%env(resolve:JWT_PUBLIC_KEY)%' - pass_phrase: '%env(JWT_PASSPHRASE)%' - # 1 month ttl - token_ttl: 2628288 diff --git a/config/packages/mercure.php b/config/packages/mercure.php new file mode 100644 index 0000000..94531fb --- /dev/null +++ b/config/packages/mercure.php @@ -0,0 +1,26 @@ +hub('default'); + $defaultHub + ->url('%env(MERCURE_URL)%') + ->publicUrl('%env(MERCURE_PUBLIC_URL)%'); + + $jwtConfig = $defaultHub->jwt(); + $jwtConfig + ->secret('%env(MERCURE_JWT_SECRET)%') + ->publish('*') + ->subscribe('*'); + + if ($containerConfigurator->env() !== 'test') { + return; + } + + $defaultHub->url('mercure')->publicUrl('public-mercure'); + $jwtConfig->secret('secret')->publish('*'); +}; diff --git a/config/packages/mercure.yaml b/config/packages/mercure.yaml deleted file mode 100644 index c843aeb..0000000 --- a/config/packages/mercure.yaml +++ /dev/null @@ -1,18 +0,0 @@ -mercure: - hubs: - default: - url: '%env(MERCURE_URL)%' - public_url: '%env(MERCURE_PUBLIC_URL)%' - jwt: - secret: '%env(MERCURE_JWT_SECRET)%' - publish: '*' - subscribe: '*' -when@test: - mercure: - hubs: - default: - url: 'mercure' - public_url: 'public-mercure' - jwt: - secret: 'secret' - publish: '*' diff --git a/config/packages/monolog.php b/config/packages/monolog.php new file mode 100644 index 0000000..fa73417 --- /dev/null +++ b/config/packages/monolog.php @@ -0,0 +1,67 @@ +channels(['deprecation']); + + if ($containerConfigurator->env() === 'dev') { + $monologConfig->handler('main') + ->type('stream') + ->path('%kernel.logs_dir%/%kernel.environment%.log') + ->level('debug') + ->channels(['elements' => ['!event']]); + + $monologConfig->handler('console') + ->type('console') + ->processPsr3Messages(false) + ->channels(['elements' => ['!event', '!doctrine', '!console']]); + } + + if ($containerConfigurator->env() === 'test') { + $mainHandler = $monologConfig->handler('main') + ->type('fingers_crossed') + ->actionLevel('error') + ->handler('nested'); + + $mainHandler->channels(['elements' => ['!event']]); + $mainHandler->excludedHttpCode()->code(404); + $mainHandler->excludedHttpCode()->code(405); + + $monologConfig->handler('nested') + ->type('stream') + ->path('%kernel.logs_dir%/%kernel.environment%.log') + ->level('debug'); + } + + if ($containerConfigurator->env() !== 'prod') { + return; + } + + $mainHandler = $monologConfig->handler('main') + ->type('fingers_crossed') + ->actionLevel('error') + ->bufferSize(50) + ->handler('nested'); + + $mainHandler->excludedHttpCode([404, 405]); + + $monologConfig->handler('nested') + ->type('rotating_file') + ->path('%kernel.logs_dir%/%kernel.environment%.log') + ->level('info') + ->maxFiles(10); + + $monologConfig->handler('console') + ->type('console') + ->processPsr3Messages(false) + ->channels(['elements' => ['!event', '!doctrine']]); + + $monologConfig->handler('deprecation') + ->type('stream') + ->path('php://stderr') + ->channels(['elements' => ['deprecation']]); +}; diff --git a/config/packages/monolog.yaml b/config/packages/monolog.yaml deleted file mode 100644 index 92992a8..0000000 --- a/config/packages/monolog.yaml +++ /dev/null @@ -1,61 +0,0 @@ -monolog: - channels: - - deprecation # Deprecations are logged in the dedicated "deprecation" channel when it exists - -when@dev: - monolog: - handlers: - main: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - channels: ["!event"] - # uncomment to get logging in your browser - # you may have to allow bigger header sizes in your Web server configuration - #firephp: - # type: firephp - # level: info - #chromephp: - # type: chromephp - # level: info - console: - type: console - process_psr_3_messages: false - channels: ["!event", "!doctrine", "!console"] - -when@test: - monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - excluded_http_codes: [404, 405] - channels: ["!event"] - nested: - type: stream - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: debug - -when@prod: - monolog: - handlers: - main: - type: fingers_crossed - action_level: error - handler: nested - excluded_http_codes: [404, 405] - buffer_size: 50 # How many messages should be saved? Prevent memory leaks - nested: - type: rotating_file - path: "%kernel.logs_dir%/%kernel.environment%.log" - level: info - max_files: 10 - console: - type: console - process_psr_3_messages: false - channels: ["!event", "!doctrine"] - deprecation: - type: stream - channels: [deprecation] - path: php://stderr diff --git a/config/packages/nelmio_cors.php b/config/packages/nelmio_cors.php new file mode 100644 index 0000000..e684ca5 --- /dev/null +++ b/config/packages/nelmio_cors.php @@ -0,0 +1,16 @@ +defaults() + ->allowCredentials(true) + ->originRegex(true) + ->allowOrigin(['%env(CORS_ALLOW_ORIGIN)%']) + ->allowMethods(['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE']) + ->allowHeaders(['Content-Type', 'Authorization']) + ->exposeHeaders(['Link']) + ->maxAge(3600); +}; diff --git a/config/packages/nelmio_cors.yaml b/config/packages/nelmio_cors.yaml deleted file mode 100644 index 4a4fd29..0000000 --- a/config/packages/nelmio_cors.yaml +++ /dev/null @@ -1,9 +0,0 @@ -nelmio_cors: - defaults: - allow_credentials: true - origin_regex: true - allow_origin: ['%env(CORS_ALLOW_ORIGIN)%'] - allow_methods: ['GET', 'OPTIONS', 'POST', 'PUT', 'PATCH', 'DELETE'] - allow_headers: ['Content-Type', 'Authorization'] - expose_headers: ['Link'] - max_age: 3600 diff --git a/config/packages/routing.php b/config/packages/routing.php new file mode 100644 index 0000000..6e6401d --- /dev/null +++ b/config/packages/routing.php @@ -0,0 +1,18 @@ +router(); + + $routerConfig->utf8(true); + + if ($containerConfigurator->env() !== 'prod') { + return; + } + + $routerConfig->strictRequirements(null); +}; diff --git a/config/packages/routing.yaml b/config/packages/routing.yaml deleted file mode 100644 index 4b766ce..0000000 --- a/config/packages/routing.yaml +++ /dev/null @@ -1,12 +0,0 @@ -framework: - router: - utf8: true - - # Configure how to generate URLs in non-HTTP contexts, such as CLI commands. - # See https://symfony.com/doc/current/routing.html#generating-urls-in-commands - #default_uri: http://localhost - -when@prod: - framework: - router: - strict_requirements: null diff --git a/config/packages/security.php b/config/packages/security.php new file mode 100644 index 0000000..f730d8b --- /dev/null +++ b/config/packages/security.php @@ -0,0 +1,37 @@ +provider('app_user_provider') + ->entity() + ->class(Player::class) + ->property('id'); + $securityConfig + ->firewall('dev') + ->pattern('^/(_(profiler|wdt)|css|images|js)/') + ->security(false); + $securityConfig + ->firewall('public') + ->pattern('^/player') + ->methods(['POST']) + ->stateless(true) + ->lazy(true) + ->provider('app_user_provider'); + $securityConfig + ->firewall('main') + ->stateless(true) + ->lazy(true) + ->provider('app_user_provider') + ->jwt(); + $securityConfig->roleHierarchy('ROLE_ADMIN', ['ROLE_USER']); + $securityConfig->roleHierarchy('ROLE_MASTER', ['ROLE_ADMIN']); + $securityConfig->accessControl()->path('^/player')->roles('PUBLIC_ACCESS')->methods(['POST']); + $securityConfig->accessControl()->path('^/player')->roles('ROLE_USER'); + $securityConfig->accessControl()->path('^/room')->roles('ROLE_USER'); + $securityConfig->accessControl()->path('^/mission')->roles('ROLE_USER'); +}; diff --git a/config/packages/security.yaml b/config/packages/security.yaml deleted file mode 100644 index e0fb741..0000000 --- a/config/packages/security.yaml +++ /dev/null @@ -1,43 +0,0 @@ -security: - # https://symfony.com/doc/current/security.html#loading-the-user-the-user-provider - providers: - # used to reload user from session & other features (e.g. switch_user) - app_user_provider: - entity: - class: App\Domain\Player\Entity\Player - property: id - # used to reload user from session & other features (e.g. switch_user) - firewalls: - dev: - pattern: ^/(_(profiler|wdt)|css|images|js)/ - security: false - public: - pattern: ^/player - methods: [POST] - stateless: true - lazy: true - provider: app_user_provider - main: - stateless: true - lazy: true - provider: app_user_provider - jwt: ~ - - # activate different ways to authenticate - # https://symfony.com/doc/current/security.html#the-firewall - - # https://symfony.com/doc/current/security/impersonating_user.html - # switch_user: true - - role_hierarchy: - ROLE_ADMIN: ROLE_USER - ROLE_MASTER: ROLE_ADMIN - - - # Easy way to control access for large sections of your site - # Note: Only the *first* access control that matches will be used - access_control: - - { path: ^/player, roles: PUBLIC_ACCESS, method: [POST] } - - { path: ^/player, roles: ROLE_USER } - - { path: ^/room, roles: ROLE_USER } - - { path: ^/mission, roles: ROLE_USER } diff --git a/config/packages/twig.php b/config/packages/twig.php new file mode 100644 index 0000000..96398b4 --- /dev/null +++ b/config/packages/twig.php @@ -0,0 +1,14 @@ +env() !== 'test') { + return; + } + + $twigConfig->strictVariables(true); +}; diff --git a/config/packages/twig.yaml b/config/packages/twig.yaml deleted file mode 100644 index 5ce2df6..0000000 --- a/config/packages/twig.yaml +++ /dev/null @@ -1,3 +0,0 @@ -when@test: - twig: - strict_variables: true diff --git a/config/packages/validator.php b/config/packages/validator.php new file mode 100644 index 0000000..5b7ac71 --- /dev/null +++ b/config/packages/validator.php @@ -0,0 +1,18 @@ +validation(); + + $validationConfig->emailValidationMode('html5'); + + if ($containerConfigurator->env() !== 'test') { + return; + } + + $validationConfig->notCompromisedPassword()->enabled(false); +}; diff --git a/config/packages/validator.yaml b/config/packages/validator.yaml deleted file mode 100644 index 0201281..0000000 --- a/config/packages/validator.yaml +++ /dev/null @@ -1,13 +0,0 @@ -framework: - validation: - email_validation_mode: html5 - - # Enables validator auto-mapping support. - # For instance, basic validation constraints will be inferred from Doctrine's metadata. - #auto_mapping: - # App\Entity\: [] - -when@test: - framework: - validation: - not_compromised_password: false diff --git a/config/packages/web_profiler.php b/config/packages/web_profiler.php new file mode 100644 index 0000000..c79d85c --- /dev/null +++ b/config/packages/web_profiler.php @@ -0,0 +1,32 @@ +profiler(); + + if ($containerConfigurator->env() === 'dev') { + $webProfilerConfig->toolbar(true); + $webProfilerConfig->interceptRedirects(true); + + $profilerConfig->onlyExceptions(false); + $profilerConfig->collectSerializerData(true); + } + + if ($containerConfigurator->env() !== 'test') { + return; + } + + $webProfilerConfig->toolbar(false); + $webProfilerConfig->interceptRedirects(false); + + $profilerConfig->collect(false); +}; diff --git a/config/packages/web_profiler.yaml b/config/packages/web_profiler.yaml deleted file mode 100644 index b946111..0000000 --- a/config/packages/web_profiler.yaml +++ /dev/null @@ -1,17 +0,0 @@ -when@dev: - web_profiler: - toolbar: true - intercept_redirects: false - - framework: - profiler: - only_exceptions: false - collect_serializer_data: true - -when@test: - web_profiler: - toolbar: false - intercept_redirects: false - - framework: - profiler: { collect: false } diff --git a/config/packages/workflow.php b/config/packages/workflow.php new file mode 100644 index 0000000..f42e9d4 --- /dev/null +++ b/config/packages/workflow.php @@ -0,0 +1,33 @@ +workflows()->workflows('room_lifecycle'); + + $roomLifecycle + ->type('state_machine') + ->supports([Room::class]) + ->initialMarking('PENDING') + ->markingStore() + ->type('method') + ->property('status'); + + $roomLifecycle->place()->name('PENDING'); + $roomLifecycle->place()->name('IN_GAME'); + $roomLifecycle->place()->name('ENDED'); + + $roomLifecycle->transition() + ->name('start_game') + ->guard('is_granted(\'edit_room\', subject)') + ->from('PENDING') + ->to('IN_GAME'); + + $roomLifecycle->transition() + ->name('end_game') + ->from('IN_GAME') + ->to('ENDED'); +}; diff --git a/config/packages/workflow.yaml b/config/packages/workflow.yaml deleted file mode 100644 index f2c037b..0000000 --- a/config/packages/workflow.yaml +++ /dev/null @@ -1,22 +0,0 @@ -framework: - workflows: - room_lifecycle: - type: 'state_machine' - marking_store: - type: 'method' - property: 'status' - supports: - - App\Domain\Room\Entity\Room - initial_marking: PENDING - places: - - PENDING - - IN_GAME - - ENDED - transitions: - start_game: - guard: "is_granted('edit_room', subject)" - from: PENDING - to: IN_GAME - end_game: - from: IN_GAME - to: ENDED