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

Create MercureOptions via inline factory instead of ValinorConfigFactory #154

Merged
merged 1 commit into from
Oct 24, 2024
Merged
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
2 changes: 0 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,3 @@ on:
jobs:
ci:
uses: shlinkio/github-actions/.github/workflows/php-lib-ci.yml@main
with:
coverage-driver: 'xdebug'
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), and this

### Changed
* Switch to xdebug for code coverage reports, as pcov is not marking functions as covered
* Remove references to `ValinorConfigFactory` from `shlinkio/shlink-config`.

### Deprecated
* *Nothing*
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@
"predis/predis": "^2.2",
"psr/http-server-middleware": "^1.0",
"ramsey/uuid": "^4.7",
"shlinkio/shlink-config": "^3.1",
"shlinkio/shlink-json": "^1.1",
"shlinkio/shlink-config": "^3.3",
"shlinkio/shlink-json": "^1.2",
"symfony/cache": "^7.1",
"symfony/lock": "^7.1",
"symfony/mercure": "^0.6",
Expand Down
12 changes: 10 additions & 2 deletions config/mercure.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

use Laminas\ServiceManager\AbstractFactory\ConfigAbstractFactory;
use Lcobucci\JWT\Configuration;
use Shlinkio\Shlink\Config\Factory\ValinorConfigFactory;
use Psr\Container\ContainerInterface;
use Symfony\Component\Mercure\Hub;

return [
Expand All @@ -19,7 +19,15 @@
Mercure\LcobucciJwtProvider::class => ConfigAbstractFactory::class,
Hub::class => Mercure\HubFactory::class,
Mercure\MercureHubPublishingHelper::class => ConfigAbstractFactory::class,
Mercure\MercureOptions::class => [ValinorConfigFactory::class, 'config.mercure'],
Mercure\MercureOptions::class => static function (ContainerInterface $c): Mercure\MercureOptions {
$config = $c->get('config.mercure');
return new Mercure\MercureOptions(
publicHubUrl: $config['public_hub_url'] ?? null,
internalHubUrl: $config['internal_hub_url'] ?? null,
jwtSecret: $config['jwt_secret'] ?? null,
jwtIssuer: $config['jwt_issuer'] ?? 'Shlink',
);
},
],
],

Expand Down
10 changes: 5 additions & 5 deletions src/Mercure/MercureOptions.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@

use function trim;

class MercureOptions
readonly class MercureOptions
{
/**
* @param non-empty-string $jwtIssuer
*/
public function __construct(
public readonly ?string $publicHubUrl = null,
public readonly ?string $internalHubUrl = null,
public readonly ?string $jwtSecret = null,
public readonly string $jwtIssuer = 'Shlink',
public ?string $publicHubUrl = null,
public ?string $internalHubUrl = null,
public ?string $jwtSecret = null,
public string $jwtIssuer = 'Shlink',
) {
}

Expand Down