[TASK] Use array access instead of traversing hook array 67/23267/5
authorBernhard Kraft <kraft@webconsulting.at>
Fri, 23 Aug 2013 08:33:50 +0000 (10:33 +0200)
committerMarkus Klein <klein.t3@mfc-linz.at>
Thu, 28 Nov 2013 23:53:45 +0000 (00:53 +0100)
Instead of making a slow array traversal simply check if there is
a hook object for the cObject being rendered by using an array access.
And check if the object exists before.

Change-Id: I6b16703b1194eca4d1ed5c3d5543076e2cae495d
Resolves: #51283
Releases: 6.2
Reviewed-on: https://review.typo3.org/23267
Reviewed-by: Oliver Klee
Reviewed-by: Philipp Gampe
Tested-by: Philipp Gampe
Reviewed-by: Helmut Hummel
Reviewed-by: Markus Klein
Tested-by: Markus Klein
typo3/sysext/frontend/Classes/ContentObject/ContentObjectRenderer.php

index cd9cc05..82b2392 100644 (file)
@@ -732,8 +732,9 @@ class ContentObjectRenderer {
                        } else {
                                $hooked = FALSE;
                                // Application defined cObjects
-                               foreach ($this->cObjHookObjectsArr as $cObjName => $hookObj) {
-                                       if ($name === $cObjName && method_exists($hookObj, 'cObjGetSingleExt')) {
+                               if (!empty($this->cObjHookObjectsArr[$name])) {
+                                       $hookObj = $this->cObjHookObjectsArr[$name];
+                                       if (method_exists($hookObj, 'cObjGetSingleExt')) {
                                                $content .= $hookObj->cObjGetSingleExt($name, $conf, $TSkey, $this);
                                                $hooked = TRUE;
                                        }