Bug #43451

Existing implementation of txCmsLayoutDrawItemHook fails in 6.0

Added by Martin Ficzel over 2 years ago. Updated about 2 years ago.

Status:Closed Start date:2012-11-29
Priority:Should have Due date:
Assigned To:- % Done:

0%

Category:- Spent time: -
Target version:-
TYPO3 Version:6.0 Is Regression:
PHP Version:5.3 Sprint Focus:
Complexity:

Description

If i implemment the following hook compatible with 4.x i get a fatal PHP-Error. Im running TYPO3 6.0 on php 5.3.6.

Error:

Fatal error: Declaration of tx_t3_default_resources_txCmsLayoutDrawItemHook::preProcess() must be compatible with that of TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface::preProcess() in /Users/martin/Public/localhost/t3_default/www-data/typo3conf/ext/t3_default_resources/Classes/Hooks/txCmsLayoutDrawItemHook.php on line 4

Hook:

$GLOBALS['TYPO3_CONF_VARS']['SC_OPTIONS']['cms/layout/class.tx_cms_layout.php']['tt_content_drawItem']

Old implementation that fails in 6.0:

class tx_t3_default_resources_txCmsLayoutDrawItemHook implements tx_cms_layout_tt_content_drawItemHook {
  public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row){
  }
}

New namespaced implementation that works but is incompatible with 4.x:

class tx_t3_default_resources_txCmsLayoutDrawItemHook implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
  public function preProcess(tx_cms_layout &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row){
  }
}

So currently it is not possible to implement this hook for 4.x and 6.0.

Regards Martin


Related issues

related to Core - Bug #40653: Namespace interfaces don't work for PHP version < 5.3.7 d... Resolved 2012-09-05
related to Core - Bug #42963: preProcess() hook invoking in some extensions in PageLayo... Closed 2012-11-14

History

#1 Updated by Martin Ficzel over 2 years ago

Sorry the correct implementation with the namespaced classes is here:

class tx_t3_default_resources_txCmsLayoutDrawItemHook implements \TYPO3\CMS\Backend\View\PageLayoutViewDrawItemHookInterface {
  public function preProcess(\TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row){
  }
}

#2 Updated by Markus Klein over 2 years ago

I fear you have to update your PHP version.

Minimum for TYPO3 CMS 6.0 is PHP 5.3.7

See also: https://typo3.org/download/

#3 Updated by Thomas Maroschik over 2 years ago

Could you try to skip the class path in the hook definition and put this information in the ext_autoload.php of the extension?

So instead writing "EXT:ext_xyz/Classes…/YourHookClass.php:YourHookClass" just "YourHookClass". By using the autoloader for the class the compatibility layer can kick in and rewrite the typehints.

#4 Updated by Ernesto Baschny over 2 years ago

  • Status changed from New to Needs Feedback

This is probably the same issue as in #40653, the solution is also presented there in my comment 11. Please confirm so that we can close this. I would then add an additional note on that original issue that other hooks might also be affected that work in a similar way.

#5 Updated by Alexander Opitz about 2 years ago

  • Status changed from Needs Feedback to Closed

No feedback for over 90 days.

Also available in: Atom PDF