This repository has been archived by the owner on Jun 23, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feature/III-1619
- Loading branch information
Showing
12 changed files
with
115 additions
and
223 deletions.
There are no files selected for viewing
This file contains 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 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 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,46 @@ | ||
<?php | ||
|
||
namespace CultuurNet\UDB3\UiTPASService\Broadway\Saga; | ||
|
||
use Broadway\Saga\MetadataInterface; | ||
|
||
/** | ||
* Copied from Broadway\Saga\Metadata\Metadata and modified to work with | ||
* namespaced event names. | ||
*/ | ||
class NamespacedEventsMetadata implements MetadataInterface | ||
{ | ||
private $criteria; | ||
|
||
/** | ||
* @param array $criteria | ||
*/ | ||
public function __construct($criteria) | ||
{ | ||
$this->criteria = $criteria; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function handles($event) | ||
{ | ||
$eventName = get_class($event); | ||
|
||
return isset($this->criteria[$eventName]); | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function criteria($event) | ||
{ | ||
$eventName = get_class($event); | ||
|
||
if (! isset($this->criteria[$eventName])) { | ||
throw new \RuntimeException(sprintf("No criteria for event '%s'.", $eventName)); | ||
} | ||
|
||
return $this->criteria[$eventName]($event); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
src/Broadway/Saga/StaticallyConfiguredSagaNamespacedEventsMetadataFactory.php
This file contains 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,29 @@ | ||
<?php | ||
|
||
namespace CultuurNet\UDB3\UiTPASService\Broadway\Saga; | ||
|
||
use Broadway\Saga\Metadata\MetadataFactoryInterface; | ||
use Broadway\Saga\Metadata\StaticallyConfiguredSagaInterface; | ||
|
||
/** | ||
* Copied from Broadway\Saga\Metadata\StaticallyConfiguredSagaMetadataFactory | ||
* and modified to return an instance of NamespacedEventsMetadata. | ||
*/ | ||
class StaticallyConfiguredSagaNamespacedEventsMetadataFactory implements MetadataFactoryInterface | ||
{ | ||
/** | ||
* {@inheritDoc} | ||
*/ | ||
public function create($saga) | ||
{ | ||
if (!($saga instanceof StaticallyConfiguredSagaInterface)) { | ||
throw new \RuntimeException( | ||
sprintf('Provided saga of class %s must implement %s', $saga, StaticallyConfiguredSagaInterface::class) | ||
); | ||
} | ||
|
||
$criteria = $saga::configuration(); | ||
|
||
return new NamespacedEventsMetadata($criteria); | ||
} | ||
} |
This file contains 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 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 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
15 changes: 3 additions & 12 deletions
15
tests/Specification/samples/organizer-with-lowercase-uitpas-label
This file contains 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 |
---|---|---|
@@ -1,17 +1,8 @@ | ||
{ | ||
"@id": "http://example.com/organizers/dba1c53d-582c-4081-a78c-b4848f9e3653", | ||
"labels": [ | ||
{ | ||
"uuid": "71945e50-2158-4922-94d2-fd1da6286b51", | ||
"name": "foo" | ||
}, | ||
{ | ||
"uuid": "12dabcf9-9598-4e8d-8642-c1af42698875", | ||
"name": "uitpas" | ||
}, | ||
{ | ||
"uuid": "9fac1824-8c65-4d0e-845f-9bef03fa05a1", | ||
"name": "bar" | ||
} | ||
"foo", | ||
"uitpas", | ||
"bar" | ||
] | ||
} |
This file contains 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 |
---|---|---|
@@ -1,11 +1,5 @@ | ||
{ | ||
"@id": "http://example.com/organizers/dba1c53d-582c-4081-a78c-b4848f9e3653", | ||
"labels": [ | ||
{ | ||
"uuid": "71945e50-2158-4922-94d2-fd1da6286b51", | ||
"name": "foo" | ||
}, | ||
{ | ||
"uuid": "12dabcf9-9598-4e8d-8642-c1af42698875", | ||
"name": "uitpas" | ||
}, | ||
"foo", | ||
"uitpas", |
This file contains 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 |
---|---|---|
@@ -1,17 +1,8 @@ | ||
{ | ||
"@id": "http://example.com/organizers/dba1c53d-582c-4081-a78c-b4848f9e3653", | ||
"labels": [ | ||
{ | ||
"uuid": "71945e50-2158-4922-94d2-fd1da6286b51", | ||
"name": "foo" | ||
}, | ||
{ | ||
"uuid": "12dabcf9-9598-4e8d-8642-c1af42698875", | ||
"name": "UiTPAS" | ||
}, | ||
{ | ||
"uuid": "9fac1824-8c65-4d0e-845f-9bef03fa05a1", | ||
"name": "bar" | ||
} | ||
"foo", | ||
"UiTPAS", | ||
"bar" | ||
] | ||
} |
This file contains 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 |
---|---|---|
@@ -1,13 +1,7 @@ | ||
{ | ||
"@id": "http://example.com/organizers/dba1c53d-582c-4081-a78c-b4848f9e3653", | ||
"labels": [ | ||
{ | ||
"uuid": "71945e50-2158-4922-94d2-fd1da6286b51", | ||
"name": "foo" | ||
}, | ||
{ | ||
"uuid": "9fac1824-8c65-4d0e-845f-9bef03fa05a1", | ||
"name": "bar" | ||
} | ||
"foo", | ||
"bar" | ||
] | ||
} |
Oops, something went wrong.