Feature #42176

Base Distribution - Work Package #45013: Flexible plugin integration (TODO: Reviews)

Improve resolving of view

Added by Bastian Waidelich over 7 years ago. Updated over 6 years ago.

Status:
Resolved
Priority:
Should have
Assignee:
Category:
MVC
Target version:
-
Start date:
2012-10-19
Due date:
% Done:

100%

Estimated time:
120.00 h
PHP Version:
Has patch:
No
Complexity:
medium

Description

Currently the resolution of a view class and the respective (fluid) template happens really early in the MVC dispatching and is not extensible from the "outside".
The actual view & template shold only be resolved while rendering the action, so one can intervene in the action.
Besides view options (e.g. template/layout/widget root paths, view class name, ...) should be overridable via YAML.

Following steps are required:

  • View::canRender() should not be called in ActionController::resolveView() (also remove it from API!)
  • remove “NotFoundView”, instead the View should throw an exception while rendering (see #40888)
  • documentation! (also include a section on how to use the template of a different action)

Views.yaml ( can be easily added through: https://review.typo3.org/#/c/11982/ ):


# Change the template root path for all packages!
-
  options:
    templateRootPaths: ['resource://My.App/Private/Templates']

# Add layout lookup path for all actions of the "Foo" controller in "Some.Package" 
-
  requestFilter: 'isPackage("Some.Package") && isController("Foo")'
  options:
    layoutRootPaths: ['resource://Other.Package/Private/Layouts', 'resource://Some.Package/Private/Layouts']

# Use a custom view for all actions of "Some.Package" if the requested format is "json" 
-
  requestFilter: 'isPackage("Some.Package") && isFormat("json")'
  viewObjectName: 'Other\Package\View\CustomView'

Note: The previous configuration format we envisioned was something like:

My:
  Package:
    viewClassName: TemplateView / TypoScriptView
    options:
      templateRootPath: resources://Other.Package/...
      layoutRootPath: ...
    controllers:
      'List':
        options:
           # ...
       widget:
         'TYPO3\TypoScript\ViewHelpers\Widget\Paginate':
           templateRootPath: ...

        actions:
          'some':
            #...

Views.schema.yaml View - YAML schema for the mentioned configuration format (1.83 KB) Bastian Waidelich, 2013-01-16 12:21


Related issues

Related to TYPO3.Fluid - Feature #33487: Configure from what package to use Templates/Partial/Layouts Closed 2012-01-27
Related to TYPO3.Fluid - Feature #39870: Allow configuration of template path fallbacks Resolved 2012-08-16
Related to TYPO3.Flow - Feature #40857: When template is automatically retrieved but not found, a hint about the tried location should be present Resolved 2012-09-12
Related to TYPO3.Flow - Bug #40888: Add ViewNotFoundException Resolved 2012-09-13
Related to TYPO3.Flow - Task #43930: Remove canRender() completely?! Needs Feedback 2012-12-12

Associated revisions

Revision 9f99c840 (diff)
Added by Bastian Waidelich about 7 years ago

[BUGFIX] Throw ViewNotFoundException if view could not be resolved

This improves the resolving of views by removing the canRender()
checks from ActionController::resolveView as discussed in #42176.

Besides this skips the creation of the obsolete NotFoundView in favor
of throwing a ViewNotFoundException.

This also adds overdue unit tests for the ActionController.

Change-Id: I27cba20836d695e46fe355bd1e4168a6fd86eb76
Fixes: #40888
Fixes: #40857
Related: #42176
Releases: 1.2

Revision 6f03a9a4 (diff)
Added by Bastian Waidelich about 7 years ago

[TASK] Remove API annotation from View::canRender()

With #40888 View::canRender() is no longer called from within
ActionController::resolveView().
As the framework no longer relies on that method to exist the
@api annotation is removed.

Besides this marks EmptyView deprecated.

Change-Id: Ia10809aed5829ee2ed2308965a0f87cfca6d182b
Related: #40888
Related: #42176
Releases: 1.2

Revision dc39b58d (diff)
Added by Marc Neuhaus over 6 years ago

[FEATURE] Allow view configuration via Views.yaml

This patch adds a new Configuration called ``Views.yaml``
to set/override various settings for Views, just
like the template path to use or controller options.

Example ``Views.yaml``::

-
requestFilter: 'isPackage("My.Package")'
viewClassName: 'TYPO3\TypoScript\View\TypoScriptView'
options:
typoScriptPathPattern: 'resource://My.Package/Private/TypoScripts'

Change I7596f6fc7f8349f3c43d05e6b5916b7946d412d5 in
Fluid takes care about this with rearranging the TemplateView.

Additionally this change introduces a dependency to TYPO3.Eel.

Change-Id: I93acc3ed3d9578a5d00d494b367aa7201138255b
Resolves: #42176
Releases: master

Revision 0346b3ef (diff)
Added by Karsten Dambekalns over 6 years ago

[BUGFIX] Use @dev version of TYPO3.Eel

Change-Id: I5b860b36f70e34afa09a2ad5bd7ae693808a5f3f
Related: #42176
Releases: master

History

#1 Updated by Gerrit Code Review over 7 years ago

  • Status changed from New to Under Review

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#2 Updated by Gerrit Code Review over 7 years ago

Patch set 1 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16393

#3 Updated by Marc Neuhaus over 7 years ago

I've created a basic WIP implementation and pushed it to gerrit.
So far it only works for ActionController, not Widgets, i've been thinking about how to
configure Widgets and got the idea, that we should use the SubRequests Namespaces here
to make it as flexible and understandable as possible:

My:
  Package:
    controllers:
      MyController:
        actions:
          someAction:
            subrequests:
              widgetNamespace:
                Some:
                  Package:
                    controllers:
                      SomeWidgetController:
                        actions:
                          first:
                            options: ...

What i don' really like, is that this become quite long and verbose :/

#4 Updated by Gerrit Code Review over 7 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#5 Updated by Gerrit Code Review over 7 years ago

Patch set 2 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16393

#6 Updated by Gerrit Code Review over 7 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#7 Updated by Gerrit Code Review over 7 years ago

Patch set 3 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16393

#8 Updated by Gerrit Code Review over 7 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#9 Updated by Gerrit Code Review over 7 years ago

Patch set 5 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#10 Updated by Gerrit Code Review over 7 years ago

Patch set 4 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16393

#11 Updated by Gerrit Code Review about 7 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#12 Updated by Gerrit Code Review about 7 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at http://review.typo3.org/16392

#13 Updated by Karsten Dambekalns about 7 years ago

  • Target version changed from 2.0 beta 1 to 2.1

#14 Updated by Bastian Waidelich about 7 years ago

Hi Marc,

I've started adjusting your patch to the current version and tweaking the configuration format (attached you'll find a simplified YAML schema for it):

My:
  Package:
    viewClassName: 'My\Custom\View' # all views that are rendered in package "My.Package" 
    controllers:
      'My\Package\Controller\FooController':
        viewClassName: 'My\Custom\View' # all views that are rendered in FooController of package "My.Package" 
        actions:
          'index':
            viewClassName: 'My\Custom\View' # all views that are rendered in indexAction of FooController of package "My.Package" 
    subRequests:
      viewClassName: 'My\Custom\View' # all views that are rendered in sub requests of package "My.Package" 
      controllers:
        'Other\Package\Controller\BarController':
          viewClassName: 'My\Custom\View' # all views that are rendered in BarController of package "Other.Package" and are sub requests within "My.Package" 
          actions:
            'index':
              viewClassName: 'TYPO3\Fluid\View\TemplateView' # all views that are rendered in indexAction of BarController of package "Other.Package" and are sub requests within "My.Package" 

In order to make this really flexible though, the subRequests key need to be allowed under "PackageKey", "controller" and "action" recursively.
This leads to a very "expensive" check for each request, especially in nested requests.
For a simple widget requests (calling "SubPackage.SubController.SubAction" in a parent request "RootPackage.RootController.RootAction") those 12 paths would need to be checked and merged:

<RootPackage>.controllers.<RootController>.actions.<RootAction>.subRequests.controllers.<SubController>.actions.<SubAction>
<RootPackage>.controllers.<RootController>.actions.<RootAction>.subRequests.controllers.<SubController>
<RootPackage>.controllers.<RootController>.actions.<RootAction>.subRequests
<RootPackage>.controllers.<RootController>.subRequests.controllers.<SubController>.actions.<SubAction>
<RootPackage>.controllers.<RootController>.subRequests.controllers.<SubController>
<RootPackage>.controllers.<RootController>.subRequests
<RootPackage>.subRequests.controllers.<SubController>.actions.<Sub1Action>
<RootPackage>.subRequests.controllers.<SubController>
<RootPackage>.subRequests
<SubPackage>.controllers.<SubController>.actions.<SubAction>
<SubPackage>.controllers.<SubController>
<SubPackage>

for more nesting levels (e.g. widget within plugin within neos page) the number of checks increases exponentially.

The more I think about it the more I'm convinced that we need some kind of pattern syntax here, similar to the Policy.yaml pointcut expressions. It's all about matching a certain request based on package, controller & action and possibly its parent request(s).

The question is: how can we make this deterministic, easy to comprehend and especially easy to override?

#15 Updated by Gerrit Code Review about 7 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#16 Updated by Gerrit Code Review about 7 years ago

Patch set 6 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#17 Updated by Gerrit Code Review about 7 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#18 Updated by Gerrit Code Review about 7 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#19 Updated by Gerrit Code Review about 7 years ago

Patch set 11 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#20 Updated by Gerrit Code Review about 7 years ago

Patch set 12 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#21 Updated by Gerrit Code Review about 7 years ago

Patch set 13 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#22 Updated by Gerrit Code Review about 7 years ago

Patch set 14 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#23 Updated by Gerrit Code Review about 7 years ago

Patch set 15 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#24 Updated by Gerrit Code Review about 7 years ago

Patch set 7 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#25 Updated by Gerrit Code Review about 7 years ago

Patch set 8 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#26 Updated by Gerrit Code Review about 7 years ago

Patch set 16 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#27 Updated by Gerrit Code Review about 7 years ago

Patch set 9 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#28 Updated by Gerrit Code Review about 7 years ago

Patch set 17 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#29 Updated by Gerrit Code Review about 7 years ago

Patch set 18 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#30 Updated by Gerrit Code Review about 7 years ago

Patch set 19 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#31 Updated by Bastian Waidelich about 7 years ago

Update for devs watching this issue:
We decided to go for a DSL (domain specific language) – probably based on TYPO3 Eel – for the configuration format in order to reduce the amount of configuration to write while increasing the flexibility massively. More details asap, stay tuned

#32 Updated by Gerrit Code Review almost 7 years ago

Patch set 20 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#33 Updated by Marc Neuhaus almost 7 years ago

We (Bastian, Sebastian and Me) just had a little Hangout about the Syntax we're going to use:

General Syntax:

-
  options: 
     layoutRootPath: ‘foo/bar’
     ...
  requestFilter: ‘...’

Available filters:

- isPackage()  1
- isController() 10
- isAction() 100
- isFormat() 1000
- mainRequest() 10000
- parentRequest() 100000

isPackage() || isPackage() => 1
isPackage() && parentRequest.isPackage() => 100001

→ Score wird NUR hochgezählt, wenn einzelner Key zutrifft! → bei OR werden nur die matchenden Teile gezählt.
→ aufsteigend sortieren.

Use cases:

Use case 1: “Change the layout of a package (in Flow)”

-
  options:
     layoutRootPath: ‘foo/bar’
  requestFilter: ‘’isPackage(‘Some.Package”) && isFormat(‘html’)”

Use case 2: “Add TypoScriptPaths to an TypoScriptView (e.g. Expose)”

-
  options: 
     layoutRootPath: ‘foo/bar’
  requestFilter: ‘’isPackage(‘TYPO3.Expose”)”

Use case 3: “Change the layout of a package only in a sub request (in Neos)”
-
  options: 
     layoutRootPath: ‘foo/bar’
  requestFilter: ‘’isPackage(‘Some.Package”) && isFormat(‘html’) && mainRequest.isPackage(‘TYPO3.Neos’)”

#34 Updated by Gerrit Code Review almost 7 years ago

Patch set 21 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#35 Updated by Gerrit Code Review almost 7 years ago

Patch set 22 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#36 Updated by Gerrit Code Review almost 7 years ago

Patch set 23 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#37 Updated by Gerrit Code Review almost 7 years ago

Patch set 24 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#38 Updated by Gerrit Code Review almost 7 years ago

Patch set 25 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#39 Updated by Marc Neuhaus almost 7 years ago

  • % Done changed from 0 to 90
  • Complexity set to medium

#40 Updated by Aske Ertmann almost 7 years ago

  • Parent task set to #45013

#41 Updated by Gerrit Code Review almost 7 years ago

Patch set 26 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#42 Updated by Aske Ertmann almost 7 years ago

  • Estimated time set to 120.00 h

#43 Updated by Gerrit Code Review almost 7 years ago

Patch set 27 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#44 Updated by Gerrit Code Review almost 7 years ago

Patch set 28 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#45 Updated by Gerrit Code Review almost 7 years ago

Patch set 29 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#46 Updated by Gerrit Code Review almost 7 years ago

Patch set 30 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#47 Updated by Gerrit Code Review almost 7 years ago

Patch set 10 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#48 Updated by Gerrit Code Review almost 7 years ago

Patch set 31 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#49 Updated by Gerrit Code Review almost 7 years ago

Patch set 11 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#50 Updated by Gerrit Code Review almost 7 years ago

Patch set 32 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#51 Updated by Gerrit Code Review almost 7 years ago

Patch set 12 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#52 Updated by Gerrit Code Review almost 7 years ago

Patch set 33 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#53 Updated by Robert Lemke almost 7 years ago

  • Target version deleted (2.1)

#54 Updated by Gerrit Code Review over 6 years ago

Patch set 13 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#55 Updated by Gerrit Code Review over 6 years ago

Patch set 34 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#56 Updated by Gerrit Code Review over 6 years ago

Patch set 14 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#57 Updated by Gerrit Code Review over 6 years ago

Patch set 15 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#58 Updated by Gerrit Code Review over 6 years ago

Patch set 35 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#59 Updated by Gerrit Code Review over 6 years ago

Patch set 36 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#60 Updated by Gerrit Code Review over 6 years ago

Patch set 37 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#61 Updated by Gerrit Code Review over 6 years ago

Patch set 38 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#62 Updated by Gerrit Code Review over 6 years ago

Patch set 39 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#63 Updated by Gerrit Code Review over 6 years ago

Patch set 40 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#64 Updated by Gerrit Code Review over 6 years ago

Patch set 16 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#65 Updated by Kay Strobach over 6 years ago

will this ported to TYPO3 CMS as well? There is an extension called view made by Claus Due, which adds similar functionality :\

#66 Updated by Marc Neuhaus over 6 years ago

This could be backported. Main issue/thing that would need to be discussed is, if Eel will be backported as well, or if the configuration will be done in typoscript somehow.

#67 Updated by Gerrit Code Review over 6 years ago

Patch set 41 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#68 Updated by Gerrit Code Review over 6 years ago

Patch set 42 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#69 Updated by Gerrit Code Review over 6 years ago

Patch set 17 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#70 Updated by Gerrit Code Review over 6 years ago

Patch set 43 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16392

#71 Updated by Gerrit Code Review over 6 years ago

Patch set 18 for branch master has been pushed to the review server.
It is available at https://review.typo3.org/16393

#72 Updated by Bastian Waidelich over 6 years ago

  • Status changed from Under Review to Resolved
  • % Done changed from 90 to 100

Also available in: Atom PDF