[TYPO3-dev] Include a hook in extension

Xavier Perseguers xavier at typo3.org
Wed Dec 4 17:43:16 CET 2013


Hi,

alkativo wrote:
> public function getPageItems($pid = 0){
>         $includestuff =
> \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('tx_realurl');

$includestuff is never used, so I really don't get why you need this.

> 
>         $return = array();
>         $aPids = $this->getPagetreeIds($pid);
> 
>         foreach ($aPids as $iPid) {
>             $return[$iPid] =
> Tx_MyOtherClass_Hooks_MyAction::getPagePathesForPid($iPid);
>         }
>         $here = '';
>     }
> 
> So in my Extension i try in one method to get a method from a other
> class. The includestuff with the sample extension is working but i can

What is working? You don't use it!

> not get the public static method from the hook. I tried something like this

Your sample shows a non-namespaced class Tx_MyOtherClass_Hooks_MyAction
whereas you use \TYPO3\CMS\Core\Utility\GeneralUtility. This suggests
that you are using TYPO3 6.x. If you are using namespace in the code
enclosing your code snippet here, you certainly have something like that:

namespace \Whatever\Something;
class YourExample {
	// your code snippet
}

so that when you write Tx_MyOtherClass_Hooks_MyAction, PHP (this has
nothing to do with TYPO3) is looking for the fully qualified class name

\Whatever\Something\Tx_MyOtherClass_Hooks_MyAction

but your Tx_My... is from another extension (and it is not using
namespaces) so that you should ask the correct class to be used:

\Tx_MyOtherClass_Hooks_MyAction::getPagePathesForPid($iPid);

(with a leading backslash).

Kind regards

-- 
Xavier Perseguers
Release Manager TYPO3 4.6

TYPO3 .... inspiring people to share!
Get involved: http://typo3.org




More information about the TYPO3-dev mailing list