Skip to content
Closed
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
7 changes: 7 additions & 0 deletions .env
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,10 @@ JWT_PASSPHRASE=
###< lexik/jwt-authentication-bundle ###

COMMUNITY_DATABASE=datas/community_database

###> symfony/messenger ###
# Choose one of the transports below
# MESSENGER_TRANSPORT_DSN=amqp://guest:guest@localhost:5672/%2f/messages
# MESSENGER_TRANSPORT_DSN=redis://localhost:6379/messages
MESSENGER_TRANSPORT_DSN=doctrine://default?auto_setup=0
###< symfony/messenger ###
2 changes: 2 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@
"symfony/form": "8.0.*",
"symfony/framework-bundle": "8.0.*",
"symfony/http-client": "8.0.*",
"symfony/messenger": "8.0.*",
"symfony/monolog-bundle": "*",
"symfony/property-access": "8.0.*",
"symfony/property-info": "8.0.*",
"symfony/runtime": "8.0.*",
"symfony/scheduler": "8.0.*",
"symfony/security-bundle": "8.0.*",
"symfony/serializer": "8.0.*",
"symfony/translation": "8.0.*",
Expand Down
177 changes: 176 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions config/packages/messenger.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
framework:
messenger:
# Uncomment this (and the failed transport below) to send failed messages to this transport for later handling.
# failure_transport: failed

transports:
# https://symfony.com/doc/current/messenger.html#transport-configuration
# async: '%env(MESSENGER_TRANSPORT_DSN)%'
# failed: 'doctrine://default?queue_name=failed'
sync: 'sync://'

routing:
# Route your messages to the transports
# 'App\Message\YourMessage': async

# when@test:
# framework:
# messenger:
# transports:
# # replace with your transport name here (e.g., my_transport: 'in-memory://')
# # For more Messenger testing tools, see https://github.com/zenstruck/messenger-test
# async: 'in-memory://'
6 changes: 3 additions & 3 deletions config/reference.php
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
* resources?: array<string, scalar|Param|null>,
* },
* messenger?: bool|array{ // Messenger configuration
* enabled?: bool|Param, // Default: false
* enabled?: bool|Param, // Default: true
* routing?: array<string, string|array{ // Default: []
* senders?: list<scalar|Param|null>,
* }>,
Expand Down Expand Up @@ -461,7 +461,7 @@
* }>,
* },
* scheduler?: bool|array{ // Scheduler configuration
* enabled?: bool|Param, // Default: false
* enabled?: bool|Param, // Default: true
* },
* disallow_search_engine_index?: bool|Param, // Enabled by default when debug is enabled. // Default: true
* http_client?: bool|array{ // HTTP Client configuration
Expand Down Expand Up @@ -1394,7 +1394,7 @@
* include_type?: bool|Param, // Always include @type in updates (including delete ones). // Default: false
* },
* messenger?: bool|array{
* enabled?: bool|Param, // Default: false
* enabled?: bool|Param, // Default: true
* },
* elasticsearch?: bool|array{
* enabled?: bool|Param, // Default: false
Expand Down
18 changes: 18 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
# Put parameters here that don't need to change on each machine where the app is deployed
# https://symfony.com/doc/current/best_practices.html#use-parameters-for-application-configuration
parameters:
app.gameplay_formats_manifest_url: 'https://altered-reunion-formats-prod.s3.fr-par.scw.cloud'
# Only these manifest format ids are synced into CardGroup.gameplayFormat.
app.gameplay_formats_allowlist: ['frontier']

services:
# default configuration for services in *this* file
Expand Down Expand Up @@ -38,6 +41,21 @@ services:
arguments:
- { timeout: 2.0, max_duration: 5.0 }

app.http_client.gameplay_formats:
class: Symfony\Component\HttpClient\HttpClient
factory: ['Symfony\Component\HttpClient\HttpClient', 'create']
arguments:
- { timeout: 5.0, max_duration: 15.0 }

App\Service\GameplayFormatManifestClient:
arguments:
$httpClient: '@app.http_client.gameplay_formats'
$baseUrl: '%app.gameplay_formats_manifest_url%'

App\Service\GameplayFormatSyncService:
arguments:
$allowedFormatIds: '%app.gameplay_formats_allowlist%'

App\Service\MeilisearchService:
arguments:
$httpClient: '@app.http_client.meilisearch'
Expand Down
26 changes: 26 additions & 0 deletions migrations/Version20260707120000.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

declare(strict_types=1);

namespace DoctrineMigrations;

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

final class Version20260707120000 extends AbstractMigration
{
public function getDescription(): string
{
return 'Add gameplay_format table to track synced manifest format versions';
}

public function up(Schema $schema): void
{
$this->addSql('CREATE TABLE gameplay_format (id VARCHAR(100) NOT NULL, name VARCHAR(255) NOT NULL, version INT NOT NULL, creation_date TIMESTAMP(0) WITHOUT TIME ZONE NOT NULL, update_date TIMESTAMP(0) WITHOUT TIME ZONE DEFAULT NULL, PRIMARY KEY (id))');
}

public function down(Schema $schema): void
{
$this->addSql('DROP TABLE gameplay_format');
}
}
47 changes: 47 additions & 0 deletions src/Command/SyncGameplayFormatsCommand.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?php

namespace App\Command;

use App\Service\GameplayFormatSyncService;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

#[AsCommand(
name: 'app:sync:gameplay-formats',
description: 'Sync CardGroup.gameplayFormat from the Altered Reunion formats manifest',
)]
class SyncGameplayFormatsCommand extends Command
{
public function __construct(
private readonly GameplayFormatSyncService $syncService,
) {
parent::__construct();
}

protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);

$results = $this->syncService->syncAll();

if (empty($results)) {
$io->success('No new or changed gameplay format version. Nothing to do.');
return Command::SUCCESS;
}

$io->table(
['Format', 'Name', 'Version', 'Added', 'Removed'],
array_map(
fn (array $r) => [$r['id'], $r['name'], $r['version'], $r['added'], $r['removed']],
$results,
),
);

$io->success(sprintf('%d gameplay format(s) synced.', count($results)));

return Command::SUCCESS;
}
}
Loading
Loading