Feature: #109263 - Expression language support for limitToPages in routing 

See forge#109263

Description 

The limitToPages option for route enhancers in the site configuration now supports Symfony Expression Language expressions in addition to plain page IDs.

Previously, limitToPages accepted only an array of integer page IDs, which required maintaining a static list that had to be updated whenever pages were added or moved. This change means string entries in the limitToPages array are evaluated as Expression Language expressions, giving integrators flexible, condition-based control over which pages a route enhancer applies to.

All entries in the array are combined via logical OR. Integer values are matched against the page ID (existing behavior), and string values are evaluated as expressions. To combine multiple conditions with logical AND, use the && operator inside a single expression string.

Use the following variables inside expressions:

  • page - The full page record as an associative array (for example, page["doktype"], page["backend_layout"], page["module"])
  • site - The current Site object
  • siteLanguage - The current SiteLanguage object

All the default Expression Language functions such as like(), env(), and feature() are also available. Extensions can register additional functions and variables for the routing Expression Language context via Configuration/ExpressionLanguage.php.

Examples 

Match pages by their page type (doktype):

config/sites/<identifier>/config.yaml
routeEnhancers:
  NewsPlugin:
    type: Extbase
    limitToPages:
      - 'page["doktype"] == 1'
    extension: News
    plugin: Pi1
    routes:
      - routePath: '/list/{page}'
        _controller: 'News::list'
      - routePath: '/detail/{news_title}'
        _controller: 'News::detail'
Copied!

Match pages by their backend layout:

config/sites/<identifier>/config.yaml
routeEnhancers:
  BlogPlugin:
    type: Extbase
    limitToPages:
      - 'page["backend_layout"] == "pagets__blog"'
    extension: Blog
    plugin: Posts
    routes:
      - routePath: '/post/{post_title}'
        _controller: 'Post::show'
Copied!

Combine integer page IDs with expression conditions (OR logic):

config/sites/<identifier>/config.yaml
routeEnhancers:
  ShopPlugin:
    type: Extbase
    limitToPages:
      - 42
      - 'page["module"] == "shop"'
    extension: Shop
    plugin: Products
    routes:
      - routePath: '/product/{product_title}'
        _controller: 'Product::show'
Copied!

Use AND logic inside a single expression:

config/sites/<identifier>/config.yaml
routeEnhancers:
  SpecialPlugin:
    type: Extbase
    limitToPages:
      - 'page["doktype"] == 1 && page["backend_layout"] == "pagets__special"'
    extension: MyExtension
    plugin: Special
    routes:
      - routePath: '/item/{item_title}'
        _controller: 'Item::show'
Copied!

Impact 

Integrators can now use dynamic, expression-based conditions in limitToPages instead of maintaining static lists of page IDs. This is fully backward compatible - existing configurations with integer-only arrays continue to work without any changes.