-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[Mercure] Add the component #28877
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
Closed
Closed
[Mercure] Add the component #28877
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
af6339b
Initial commit
dunglas 0a10352
Messenger support
dunglas 899d06b
Remove the messenger handler (use Publisher directly)
dunglas 0f6bfde
Handle errors. FWBundle config.
dunglas c368233
CS
dunglas cf5273e
Update for Mercure 0.2
dunglas ce7be48
Review
dunglas 661005b
Fix tests
dunglas 06b812b
Fix CS
dunglas a381f46
Fix remaining old URLs
dunglas 421279d
Fix tests
dunglas 75b4a9b
Mark the component as experimental
dunglas 0645bcd
Add some useful container's parameters
dunglas File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,7 @@ | |
use Symfony\Component\HttpFoundation\Cookie; | ||
use Symfony\Component\Lock\Lock; | ||
use Symfony\Component\Lock\Store\SemaphoreStore; | ||
use Symfony\Component\Mercure\Update; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
use Symfony\Component\PropertyInfo\PropertyInfoExtractorInterface; | ||
use Symfony\Component\Security\Csrf\CsrfTokenManagerInterface; | ||
|
@@ -35,6 +36,7 @@ | |
* | ||
* @author Jeremy Mikola <[email protected]> | ||
* @author Grégoire Pineau <[email protected]> | ||
* @author Kévin Dunglas <[email protected]> | ||
*/ | ||
class Configuration implements ConfigurationInterface | ||
{ | ||
|
@@ -106,6 +108,7 @@ public function getConfigTreeBuilder() | |
$this->addWebLinkSection($rootNode); | ||
$this->addLockSection($rootNode); | ||
$this->addMessengerSection($rootNode); | ||
$this->addMercureSection($rootNode); | ||
|
||
return $treeBuilder; | ||
} | ||
|
@@ -1132,4 +1135,36 @@ function ($a) { | |
->end() | ||
; | ||
} | ||
|
||
private function addMercureSection(ArrayNodeDefinition $rootNode) | ||
{ | ||
$rootNode | ||
->children() | ||
->arrayNode('mercure') | ||
->info('Mercure configuration') | ||
->{!class_exists(FullStack::class) && class_exists(Update::class) ? 'canBeDisabled' : 'canBeEnabled'}() | ||
->fixXmlConfig('hub') | ||
->children() | ||
->arrayNode('hubs') | ||
->useAttributeAsKey('name') | ||
->normalizeKeys(false) | ||
->arrayPrototype() | ||
->children() | ||
->scalarNode('url')->info('URL of the hub\'s publish endpoint')->example('https://demo.mercure.rocks/hub')->end() | ||
->scalarNode('jwt')->info('JSON Web Token to use to publish to this hub.')->end() | ||
->scalarNode('jwt_provider')->info('The ID of a service to call to generate the JSON Web Token.')->end() | ||
->scalarNode('bus')->info('Name of the Messenger bus where the handler for this hub must be registered. Default to the default bus if Messenger is enabled.')->end() | ||
->end() | ||
->validate() | ||
->ifTrue(function ($v) { return isset($v['jwt']) && isset($v['jwt_provider']); }) | ||
->thenInvalid('"jwt" and "jwt_provider" cannot be used together.') | ||
->end() | ||
->end() | ||
->end() | ||
->scalarNode('default_hub')->end() | ||
->end() | ||
->end() | ||
->end() | ||
; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/php/mercure.php
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
$container->loadFromExtension('framework', array( | ||
'mercure' => array( | ||
'hubs' => array( | ||
array( | ||
'name' => 'default', | ||
'url' => 'https://demo.mercure.rocks/hub', | ||
'jwt' => 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU', | ||
), | ||
), | ||
), | ||
)); |
13 changes: 13 additions & 0 deletions
13
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/xml/mercure.xml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<container xmlns="http://symfony.com/schema/dic/services" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xmlns:framework="http://symfony.com/schema/dic/symfony" | ||
xsi:schemaLocation="http://symfony.com/schema/dic/services http://symfony.com/schema/dic/services/services-1.0.xsd | ||
http://symfony.com/schema/dic/symfony http://symfony.com/schema/dic/symfony/symfony-1.0.xsd"> | ||
|
||
<framework:config> | ||
<framework:mercure> | ||
<framework:hub name="default" url="https://demo.mercure.rocks/hub" jwt="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU" /> | ||
</framework:mercure> | ||
</framework:config> | ||
</container> |
6 changes: 6 additions & 0 deletions
6
src/Symfony/Bundle/FrameworkBundle/Tests/DependencyInjection/Fixtures/yml/mercure.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
framework: | ||
mercure: | ||
hubs: | ||
default: | ||
url: https://demo.mercure.rocks/hub | ||
jwt: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.e30.HB0k08BaV8KlLZ3EafCRlTDGbkd9qdznCzJQ_l8ELTU |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
CHANGELOG | ||
========= | ||
|
||
4.2.0 | ||
----- | ||
|
||
* Introduced the component as experimental |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Symfony package. | ||
* | ||
* (c) Fabien Potencier <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Symfony\Component\Mercure\Jwt; | ||
|
||
/** | ||
* Provides a JWT passed as a configuration parameter. | ||
* | ||
* @author Kévin Dunglas <[email protected]> | ||
* | ||
* @experimental | ||
*/ | ||
final class StaticJwtProvider | ||
{ | ||
private $jwt; | ||
|
||
public function __construct(string $jwt) | ||
{ | ||
$this->jwt = $jwt; | ||
} | ||
|
||
public function __invoke(): string | ||
{ | ||
return $this->jwt; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
Copyright (c) 2018 Fabien Potencier | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is furnished | ||
to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.