changing the format of the expression detections to avoid accidently being identified as objectaccessor and adding a test, where that happend with the previous expression
Some checks failed
ci/woodpecker/push/code-style Pipeline was successful
ci/woodpecker/push/functional-tests/1 Pipeline failed
ci/woodpecker/push/functional-tests/2 Pipeline failed
ci/woodpecker/push/functional-tests/3 Pipeline failed
ci/woodpecker/push/functional-tests/4 Pipeline failed

This commit is contained in:
Ferdinand Kuhl 2024-05-30 15:08:53 +02:00
parent b3430789ec
commit f75b21a874
6 changed files with 47 additions and 13 deletions

View file

@ -16,7 +16,7 @@ class CurrentControllerExpressionNode extends AbstractExpressionNode implements
* note: this could be readonly in PHP8 * note: this could be readonly in PHP8
* @var string * @var string
*/ */
public static string $detectionExpression = '/{currentController:([a-z0-9]+)}/i'; public static string $detectionExpression = '/\{#currentController\.([a-z0-9]+)\}/';
public static function evaluateExpression(RenderingContextInterface $renderingContext, $expression, array $matches) public static function evaluateExpression(RenderingContextInterface $renderingContext, $expression, array $matches)
{ {

View file

@ -0,0 +1,6 @@
<f:render section="Test" arguments="{controllername: '{#currentController.name}'}" /><f:section name="Test">{controllername}
{#currentController.actionName}
{#currentController.packageKey}
{#currentController.subpackageKey}
{#currentController.objectName}
{#currentController.format}</f:section>

View file

@ -1,6 +1,6 @@
{currentController:name} {#currentController.name}
{currentController:actionName} {#currentController.actionName}
{currentController:packageKey} {#currentController.packageKey}
{currentController:subpackageKey} {#currentController.subpackageKey}
{currentController:objectName} {#currentController.objectName}
{currentController:format} {#currentController.format}

View file

@ -1,7 +1,7 @@
<f:layout name="Test" /> <f:layout name="Test" />
<f:section name="Content">{currentController:name} <f:section name="Content">{#currentController.name}
{currentController:actionName} {#currentController.actionName}
{currentController:packageKey} {#currentController.packageKey}
{currentController:subpackageKey} {#currentController.subpackageKey}
{currentController:objectName} {#currentController.objectName}
{currentController:format}</f:section> {#currentController.format}</f:section>

View file

@ -49,7 +49,13 @@ html
', ',
(string)$response->getBody() (string)$response->getBody()
); );
}
/**
* @test
*/
public function itReturnsCurrentControllerInformationsUsedInLayouts(): void
{
$response = $this->browser->request('http://localhost/test/currentcontrollerexpressions/test/withlayout'); $response = $this->browser->request('http://localhost/test/currentcontrollerexpressions/test/withlayout');
static::assertEquals( static::assertEquals(
'Test 'Test
@ -58,6 +64,24 @@ DigiComp.FluidCurrentControllerExpression
Tests\Functional\Fixtures Tests\Functional\Fixtures
DigiComp\FluidCurrentControllerExpression\Tests\Functional\Fixtures\Controller\TestController DigiComp\FluidCurrentControllerExpression\Tests\Functional\Fixtures\Controller\TestController
html html
',
(string)$response->getBody()
);
}
/**
* @test
*/
public function itReturnsCurrentControllerInformationsUsedInArrays(): void
{
$response = $this->browser->request('http://localhost/test/currentcontrollerexpressions/test/inArrays');
static::assertEquals(
'Test
inArrays
DigiComp.FluidCurrentControllerExpression
Tests\Functional\Fixtures
DigiComp\FluidCurrentControllerExpression\Tests\Functional\Fixtures\Controller\TestController
html
', ',
(string)$response->getBody() (string)$response->getBody()
); );

View file

@ -15,4 +15,8 @@ class TestController extends ActionController
public function withLayoutAction() public function withLayoutAction()
{ {
} }
public function inArraysAction()
{
}
} }