Search code examples
typo3typoscripttypo3-9.x

TypoScript applicationContext condition with wildcards or sub-contexts not possible


Since TYPO3 9.5 LTS suggests to use the Symfony Expression Language for TypoScript conditions.

I have some troubles migrating them:

Old Syntax:

// Matches any applicationContext with a rootContext of "Production", for example "Production/Live" or "Production/Staging":
[applicationContext = Development*]

// Matches any applicationContext starting with "Production/Dev"
[applicationContext = /^Production\/Dev/]

to the new expression language:

I've tried the following without success:

[applicationContext == "/^Development\/Docker/"]

[applicationContext == "Development*"]

[applicationContext == "Development/*"]

I didn't found any examples. I'm not sure, if the tests for conditions are already based on the expression language. (https://review.typo3.org/#/c/57787/)

Would be nice if someone has an advice how to use the feature to add conditions like before


Solution

  • You need to use the matches comparison operator of the Symfony Expression Language. This way you can use regular expressions for partial matches:

    [applicationContext matches "/^Development/"]
    

    This will match any Development context.