Uploaded image for project: 'eZ Publish / Platform'
  1. eZ Publish / Platform
  2. EZP-20438

Make it possible to use a custom controller to handle a content/location

    XMLWordPrintable

    Details

      Description

      Proposition:

      The base idea is to be able to run custom code that injects additional variables in the view template.

      For instance, it would be possible to attach a service to any override rule. This service would implement an interface that allows to:
      1. inject custom variables in the view
      2. change the etag of the response so that the cache takes care of the custom logic for the view.

      Reasons

      Currently, in Content or Location views, you only have access to the Location and the associated Content. In most cases, that's not enough to generate any non trivial view.

      To workaround, those issues you have 4 options:
      1. write a twig extensions with functions/filters that fetch some missing data, that's more or less the revival of our eZ 3/4 fetch functions, to me it's a bad practice and this should be avoided. And this would also cause cache issues.
      2. Exposes services in the template, that's more or less the same as the previous point.
      3. use the PreContentViewEvent, unfortunately, those events are global (ie triggered for every views) and it's not very easy/clean to figure out in which case you are. In addition, that's not really cache friendly.
      4. use a sub-request. This is probably the cleanest way for now, but this has some performances impacts, that's not that easy to do and for some use cases, this feels wrong.

      References forum posts:

      Solution

      Let the developer use his own custom controller to handle Content/Location objects.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              Unassigned
              Reporter:
              damien.pobel-obsolete@ez.no Damien Pobel (Inactive)
              Votes:
              2 Vote for this issue
              Watchers:
              8 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:

                  Time Tracking

                  Estimated:
                  Original Estimate - 3 days Original Estimate - 3 days
                  3d
                  Remaining:
                  Remaining Estimate - 0 minutes
                  0m
                  Logged:
                  Time Spent - 1 week, 1 day, 2 hours, 15 minutes
                  1w 1d 2h 15m