Skip to content

Commit

Permalink
Merge pull request #154 from acelaya-forks/feature/remove-valinor-fac…
Browse files Browse the repository at this point in the history
…tory

Create MercureOptions via inline factory instead of ValinorConfigFactory
  • Loading branch information
acelaya authored Oct 24, 2024
2 parents e0c872c + 0ee3ea4 commit 16d19b7
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 11 deletions.
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

0 comments on commit 16d19b7

Please sign in to comment.