문제

I have created an extension with plugins in a vendor namespace. Everything works fine so far. All the classes start with a namespace declaration namespace \VENDOR\ExtensionName\... and typo3 autoloads them just fine.

However, the problem starts when I add a ViewHelper. I put this in the \VENDOR\ExtensionName\ViewHelpers namespace. I added the namespace in my Fluid template like so: {namespace ns=VENDOR\ExtensionName\ViewHelpers}. When I call it in the template with <ns:myViewHelper />, I just get an 'Oops ...' error message:

Could not analyse class:VENDOR\ExtensionName\ViewHelpers\MyViewHelperViewHelper maybe not loaded or no autoloader?

The same happens, when I put the ViewHelper in a \TYPO3\... namespace.

How do I correctly implement a ViewHelper in an extension with a vendor namespace?

도움이 되었습니까?

해결책

The namespace declaration must not have a leading backslash.

Instead having \Vendor\ExtensionName\ViewHelpers; it has to be Vendor\ExtensionName\ViewHelpers;

http://www.php.net/manual/en/language.namespaces.nested.php

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top