-
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.
feat: make the condition resolver available in a static routes (#1820…
…) (#1823) | Q | A | ------------- | --- | Bug fix? | no | New feature? | yes | Doc PR? | no | Backport | 0.10, 0.11, 0.12 | License | MIT * Make the condition resolver available in a static routes over the request context (cherry picked from commit 2f3f955e136fc66e47a9b99f3bc56baa897b65dd) Co-authored-by: Gerhard Seidel <[email protected]>
- Loading branch information
1 parent
390fdfc
commit be1dbd7
Showing
3 changed files
with
40 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?php | ||
|
||
namespace Enhavo\Bundle\RoutingBundle\Request; | ||
|
||
use Enhavo\Bundle\RoutingBundle\Condition\ConditionResolverInterface; | ||
|
||
/** | ||
* We want to use the resolver in static routes. Unlike in cmf routing, the static routes getting compiled to php | ||
* for faster execution. So it is hard to inject further variables to the condition language expression. Thus, we abuse | ||
* the request context to inject our condition resolver to make it available in any static routing condition expression. | ||
*/ | ||
class RequestContext extends \Symfony\Component\Routing\RequestContext | ||
{ | ||
private ?ConditionResolverInterface $resolver; | ||
|
||
public function resolve() | ||
{ | ||
return $this->resolver->resolve(); | ||
} | ||
|
||
public function getResolver(): ?ConditionResolverInterface | ||
{ | ||
return $this->resolver; | ||
} | ||
|
||
public function setResolver(?ConditionResolverInterface $resolver): void | ||
{ | ||
$this->resolver = $resolver; | ||
} | ||
} |
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