Follow-up to use object manager to create object instances
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 13 Feb 2013 23:45:01 +0000 (23:45 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Wed, 13 Feb 2013 23:45:01 +0000 (23:45 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/sr_freecap/trunk@71189 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Classes/Controller/AudioPlayerController.php
Classes/Controller/FontMakerController.php
Classes/Controller/ImageGeneratorController.php
Classes/Utility/EidUtility.php
Classes/Utility/FontMakingUtility.php
Resources/Private/Eid/EidDispatcher.php

index 4a1caa0..308cc70 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * Add option to configure the encryption algorithm in Extension Manager
        * Disable the audio feature on iOS devices
        * Use object manager to create object instances
+       * Follow-up to use object manager to create object instances
 
 2013-02-12  Stanislas Rolland  <typo3@sjbr.ca>
 
index e16176a..4179708 100644 (file)
@@ -49,7 +49,7 @@ class AudioPlayerController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionCont
         */
        public function initializeAction() {
                // Get an instance of the word repository
-               $this->wordRepository = $this->objectManager->get('SJBR\SrFreecap\Domain\Repository\WordRepository');
+               $this->wordRepository = $this->objectManager->get('SJBR\\SrFreecap\\Domain\\Repository\\WordRepository');
        }
 
        /**
index ff2018b..a8c8246 100644 (file)
@@ -45,7 +45,7 @@ class FontMakerController  extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionContr
         */
        public function newAction(\SJBR\SrFreecap\Domain\Model\Font $font = NULL) {
                if (!is_object($font)) {
-                       $font = $this->objectManager->create('SJBR\SrFreecap\Domain\Model\Font');
+                       $font = $this->objectManager->create('SJBR\\SrFreecap\\Domain\\Model\\Font');
                }
                $this->view->assign('font', $font);
        }       
@@ -60,7 +60,7 @@ class FontMakerController  extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionContr
                // Create the font data
                $font->createGdFontFile();
                // Store the GD font file
-               $fontRepository = $this->objectManager->get('SJBR\SrFreecap\Domain\Repository\FontRepository');
+               $fontRepository = $this->objectManager->get('SJBR\\SrFreecap\\Domain\\Repository\\FontRepository');
                $fontRepository->writeFontFile($font);
                $this->view->assign('font', $font);
        }
index 2c7b1c2..68c1f0b 100644 (file)
@@ -54,7 +54,7 @@ class ImageGeneratorController extends \TYPO3\CMS\Extbase\Mvc\Controller\ActionC
         */
        public function initializeAction() {
                // Get an instance of the word repository
-               $this->wordRepository = $this->objectManager->get('SJBR\SrFreecap\Domain\Repository\WordRepository');
+               $this->wordRepository = $this->objectManager->get('SJBR\\SrFreecap\\Domain\\Repository\\WordRepository');
        }
 
        /**
index 4b0fbd9..eaa3bcf 100644 (file)
@@ -82,6 +82,14 @@ class EidUtility {
        protected $pageUid;
 
        /**
+        * Constructor
+        *
+        */
+       public function __construct() {
+               $this->objectManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
+       }
+
+       /**
         * Initializes and dispatches actions
         *
         * Call this function if you want to use this dispatcher "standalone"
@@ -99,14 +107,16 @@ class EidUtility {
         *
         */
        protected function dispatch() {
-               $bootstrap = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Core\\Bootstrap');
+               /* @var $bootstrap \TYPO3\CMS\Extbase\Core\Bootstrap */
+               $bootstrap = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Core\\Bootstrap');
                $configuration['extensionName'] = $this->extensionName;
                $configuration['pluginName'] = $this->pluginName;
                $bootstrap->initialize($configuration);
-               $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
                $request = $this->buildRequest();
-               $response = $this->objectManager->create('TYPO3\CMS\Extbase\MVC\Web\Response');
-               $dispatcher =  $this->objectManager->get('TYPO3\CMS\Extbase\MVC\Dispatcher');
+               /* @var $response \TYPO3\CMS\Extbase\MVC\Web\Response */
+               $response = $this->objectManager->create('TYPO3\\CMS\\Extbase\\MVC\\Web\\Response');
+               /* @var $dispatcher \TYPO3\CMS\Extbase\MVC\Dispatcher */
+               $dispatcher = $this->objectManager->get('TYPO3\\CMS\\Extbase\\MVC\\Dispatcher');
                $dispatcher->dispatch($request, $response);
                return $response->getContent();
        }
@@ -126,8 +136,8 @@ class EidUtility {
                }
                $this->pageUid = htmlspecialchars($this->pageUid);
                $MP = htmlspecialchars(\TYPO3\CMS\Core\Utility\GeneralUtility::_GET('MP'));
-               $GLOBALS['TSFE'] = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $this->pageUid, '0', TRUE, '', '', $MP, '');
-               $GLOBALS['TSFE']->sys_page = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
+               $GLOBALS['TSFE'] = $this->objectManager->get('TYPO3\\CMS\\Frontend\\Controller\\TypoScriptFrontendController', $GLOBALS['TYPO3_CONF_VARS'], $this->pageUid, '0', TRUE, '', '', $MP, '');
+               $GLOBALS['TSFE']->sys_page = $this->objectManager->get('TYPO3\\CMS\\Frontend\\Page\\PageRepository');
                $GLOBALS['TSFE']->initFeUser();
                $GLOBALS['TSFE']->determineId();
                $GLOBALS['TSFE']->getCompressedTCarray();
@@ -165,7 +175,7 @@ class EidUtility {
         */
        protected function buildRequest() {
                /* @var $request \TYPO3\CMS\Extbase\MVC\Web\Request */
-               $request = $this->objectManager->get('TYPO3\CMS\Extbase\MVC\Web\Request');
+               $request = $this->objectManager->get('TYPO3\\CMS\\Extbase\\MVC\\Web\\Request');
                $request->setControllerExtensionName($this->extensionName);
                $request->setPluginName($this->pluginName);
                $request->setControllerName($this->controllerName);
index deafa90..117dfcf 100644 (file)
@@ -77,7 +77,7 @@ class FontMakingUtility {
                        $gifObjArray[$ic . '0.']['offset'] = (($ic-1) * $width + $hOffset) . ',' . $vertOffset;
                }
                $objectManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
-               $gifCreator = $objectManager->create('SJBR\SrFreecap\Utility\GifBuilderUtility');
+               $gifCreator = $objectManager->create('SJBR\\SrFreecap\\Utility\\GifBuilderUtility');
                $gifCreator->init();
                if ($GLOBALS['TYPO3_CONF_VARS']['GFX']['gdlib']) {
                        $gifCreator->start($gifObjArray, array());
index a571662..696f419 100644 (file)
 if (!defined('TYPO3_MODE') || TYPO3_MODE !== 'FE') {
        die('Could not access this script directly!');
 }
+/** @var $objectManager \TYPO3\CMS\Extbase\Object\ObjectManagerInterface */
+$objectManager = new \TYPO3\CMS\Extbase\Object\ObjectManager();
 // Handover to the Eid Utility Object
 /** @var $dispatcher SJBR\SrFreecap\Utility\EidUtility */
-$dispatcher = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('SJBR\\SrFreecap\\Utility\\EidUtility');
+$dispatcher = $objectManager->get('SJBR\\SrFreecap\\Utility\\EidUtility');
 echo $dispatcher->initAndDispatch();
 ?>