[TASK] Remove initialization for fileFactory in AbstractContentObject 43/37843/4
authorWouter Wolters <typo3@wouterwolters.nl>
Sat, 14 Mar 2015 16:26:59 +0000 (17:26 +0100)
committerMarkus Klein <klein.t3@reelworx.at>
Sun, 15 Mar 2015 17:38:27 +0000 (18:38 +0100)
Resolves: #65734
Releases: master
Change-Id: I373838b19ebc6e4df010af498d4433ccbdb835c7
Reviewed-on: http://review.typo3.org/37843
Reviewed-by: Stephan Großberndt <stephan@grossberndt.de>
Reviewed-by: Markus Klein <klein.t3@reelworx.at>
Tested-by: Stephan Großberndt <stephan@grossberndt.de>
Tested-by: Markus Klein <klein.t3@reelworx.at>
typo3/sysext/compatibility6/Classes/ContentObject/ImageTextContentObject.php
typo3/sysext/compatibility6/Classes/ContentObject/OffsetTableContentObject.php
typo3/sysext/compatibility6/Classes/ContentObject/SearchResultContentObject.php
typo3/sysext/frontend/Classes/ContentObject/AbstractContentObject.php

index 0e6ad6d..d4089af 100644 (file)
@@ -14,6 +14,9 @@ namespace TYPO3\CMS\Compatibility6\ContentObject;
  * The TYPO3 project - inspiring people to share!
  */
 
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Core\Resource\ResourceFactory;
+
 /**
  * Contains IMGTEXT content object.
  *
@@ -22,6 +25,11 @@ namespace TYPO3\CMS\Compatibility6\ContentObject;
  */
 class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractContentObject {
 
+       /**
+        * @var ResourceFactory
+        */
+       protected $fileFactory = NULL;
+
        /**
         * Rendering the cObject, IMGTEXT
         * which is a text w/ image type that works with the image position through tables (pre-CSS styled content-time)
@@ -38,7 +46,7 @@ class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractC
                }
                $imgList = isset($conf['imgList.']) ? trim($this->cObj->stdWrap($conf['imgList'], $conf['imgList.'])) : trim($conf['imgList']);
                if ($imgList) {
-                       $imgs = \TYPO3\CMS\Core\Utility\GeneralUtility::trimExplode(',', $imgList, TRUE);
+                       $imgs = GeneralUtility::trimExplode(',', $imgList, TRUE);
                        $imgStart = isset($conf['imgStart.']) ? (int)$this->cObj->stdWrap($conf['imgStart'], $conf['imgStart.']) : (int)$conf['imgStart'];
                        $imgCount = count($imgs) - $imgStart;
                        $imgMax = isset($conf['imgMax.']) ? (int)$this->cObj->stdWrap($conf['imgMax'], $conf['imgMax.']) : (int)$conf['imgMax'];
@@ -156,7 +164,7 @@ class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractC
                        $equalHeight = isset($conf['equalH.']) ? (int)$this->cObj->stdWrap($conf['equalH'], $conf['equalH.']) : (int)$conf['equalH'];
                        // Initiate gifbuilder object in order to get dimensions AND calculate the imageWidth's
                        if ($equalHeight) {
-                               $gifCreator = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
+                               $gifCreator = GeneralUtility::makeInstance(\TYPO3\CMS\Frontend\Imaging\GifBuilder::class);
                                $gifCreator->init();
                                $relations = array();
                                $relations_cols = array();
@@ -483,7 +491,20 @@ class ImageTextContentObject extends \TYPO3\CMS\Frontend\ContentObject\AbstractC
         * @return void
         */
        protected function setCurrentFileInContentObjectRenderer($fileUid) {
-               $imageFile = $this->fileFactory->getFileReferenceObject($fileUid);
+               $imageFile = $this->getFileFactory()->getFileReferenceObject($fileUid);
                $this->cObj->setCurrentFile($imageFile);
        }
+
+       /**
+        * Returns the file factory.
+        *
+        * @return ResourceFactory
+        */
+       public function getFileFactory() {
+               if ($this->fileFactory === NULL) {
+                       $this->fileFactory = GeneralUtility::makeInstance(ResourceFactory::class);
+               }
+
+               return $this->fileFactory;
+       }
 }
index cca9238..b50ea4f 100644 (file)
@@ -43,7 +43,6 @@ class OffsetTableContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstrac
        public function __construct(\TYPO3\CMS\Frontend\ContentObject\ContentObjectRenderer $cObj = NULL) {
                if (!is_null($cObj)) {
                        $this->cObj = $cObj;
-                       $this->fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
                }
        }
 
index ec0dad7..84d7718 100644 (file)
@@ -127,7 +127,6 @@ class SearchResultContentObject extends \TYPO3\CMS\Frontend\ContentObject\Abstra
        public function __construct(ContentObjectRenderer $cObj = NULL) {
                if (!is_null($cObj)) {
                        $this->cObj = $cObj;
-                       $this->fileFactory = \TYPO3\CMS\Core\Resource\ResourceFactory::getInstance();
                }
        }
 
index 5287243..c21bb84 100644 (file)
@@ -13,7 +13,6 @@ namespace TYPO3\CMS\Frontend\ContentObject;
  *
  * The TYPO3 project - inspiring people to share!
  */
-use TYPO3\CMS\Core\Resource\ResourceFactory;
 
 /**
  * Contains an abstract class for all tslib content class implementations.
@@ -28,11 +27,6 @@ abstract class AbstractContentObject {
         */
        protected $cObj;
 
-       /**
-        * @var ResourceFactory
-        */
-       protected $fileFactory = NULL;
-
        /**
         * Default constructor.
         *
@@ -40,7 +34,6 @@ abstract class AbstractContentObject {
         */
        public function __construct(ContentObjectRenderer $cObj) {
                $this->cObj = $cObj;
-               $this->fileFactory = ResourceFactory::getInstance();
        }
 
        /**