[+BUGFIX] Fluid: Adjust Fluid to Dependency Injection changes
authorSebastian Kurfürst <sebastian@typo3.org>
Tue, 2 Nov 2010 13:24:45 +0000 (13:24 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Tue, 2 Nov 2010 13:24:45 +0000 (13:24 +0000)
Relates to: #9062

typo3/sysext/fluid/Classes/Compatibility/ObjectManager.php
typo3/sysext/fluid/Classes/Core/Parser/ParsingState.php
typo3/sysext/fluid/Classes/Core/Parser/TemplateParser.php
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContext.php
typo3/sysext/fluid/Classes/Core/Rendering/RenderingContextInterface.php
typo3/sysext/fluid/Classes/Core/ViewHelper/AbstractTagBasedViewHelper.php
typo3/sysext/fluid/Classes/View/AbstractTemplateView.php
typo3/sysext/fluid/Classes/ViewHelpers/Format/CropViewHelper.php

index 2a3f083..70c1cd6 100644 (file)
  * DO NOT USE DIRECTLY!
  * @internal
  */
-class Tx_Fluid_Compatibility_ObjectManager implements t3lib_Singleton {
-
-       protected $injectors = array(
-               'Tx_Fluid_ViewHelpers_Form_AbstractFormViewHelper' => array(
-                       'injectPersistenceManager' => 'Tx_Extbase_Persistence_Manager'
-               ),
-               'Tx_Fluid_Core_ViewHelper_AbstractViewHelper' => array(
-                       'injectReflectionService' => 'Tx_Extbase_Reflection_Service'
-               ),
-               'Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper' => array(
-                       'injectTagBuilder' => 'Tx_Fluid_Core_ViewHelper_TagBuilder'
-               ),
-               'Tx_Fluid_Core_Parser_ParsingState' => array(
-                       'injectVariableContainer' => 'Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'
-               ),
-
-               'Tx_Fluid_Core_Parser_TemplateParser' => array(
-                       'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager'
-               ),
-               'Tx_Fluid_Core_Rendering_RenderingContextInterface' => array(
-                       'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager',
-                       'injectTemplateVariableContainer' => 'Tx_Fluid_Core_ViewHelper_TemplateVariableContainer',
-                       'injectViewHelperVariableContainer' => 'Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer'
-               ),
-               'Tx_Fluid_Core_Parser_Interceptor_Escape' => array(
-                       'injectObjectManager' => 'Tx_Fluid_Compatibility_ObjectManager'
-               ),
-               'Tx_Extbase_Validation_ValidatorResolver' => array(
-                       'injectObjectManager' => 'Tx_Extbase_Object_Manager'
-               ),
-               'Tx_Fluid_ViewHelpers_FormViewHelper' => array(
-                       'injectRequestHashService' => 'Tx_Extbase_Security_Channel_RequestHashService'
-               )
-       );
-
-       /**
-        * Create a certain object name
-        *
-        * DO NOT USE DIRECTLY!
-        *
-        * @param string $objectName Object name to create
-        * @return object Object which was created
-        * @internal
-        */
-       public function create($objectName) {
-               $constructorArguments = func_get_args();
-
-               $object = call_user_func_array(array('t3lib_div', 'makeInstance'), $constructorArguments);
-               $injectObjects = array();
-
-               if (isset($this->injectors[$objectName])) {
-                       $injectObjects = array_merge($injectObjects, $this->injectors[$objectName]);
-               }
-               foreach (class_parents($objectName) as $parentObjectName) {
-                       if (isset($this->injectors[$parentObjectName])) {
-                               $injectObjects = array_merge($injectObjects, $this->injectors[$parentObjectName]);
-                       }
-               }
-               foreach (class_implements($objectName) as $parentObjectName) {
-                       if (isset($this->injectors[$parentObjectName])) {
-                               $injectObjects = array_merge($injectObjects, $this->injectors[$parentObjectName]);
-                       }
-               }
-               foreach ($injectObjects as $injectMethodName => $injectObjectName) {
-                       call_user_func(array($object, $injectMethodName), $this->create($injectObjectName));
-               }
-               return $object;
-       }
-
-       public function get($objectName) {
-               return $this->create($objectName);
-       }
+class Tx_Fluid_Compatibility_ObjectManager extends Tx_Extbase_Object_ObjectManager {
 }
 
 ?>
\ No newline at end of file
index 3759c99..56eac4c 100644 (file)
@@ -57,7 +57,7 @@ class Tx_Fluid_Core_Parser_ParsingState implements Tx_Fluid_Core_Parser_ParsedTe
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function injectVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
+       public function setVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $variableContainer) {
                $this->variableContainer = $variableContainer;
        }
 
index 78bc7d9..2a348c4 100644 (file)
@@ -25,7 +25,7 @@
  *
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  */
-class Tx_Fluid_Core_Parser_TemplateParser {
+class Tx_Fluid_Core_Parser_TemplateParser implements t3lib_Singleton {
 
        public static $SCAN_PATTERN_NAMESPACEDECLARATION = '/(?<!\\\\){namespace\s*([a-zA-Z]+[a-zA-Z0-9]*)\s*=\s*((?:F3|Tx)(?:FLUID_NAMESPACE_SEPARATOR\w+)+)\s*}/m';
 
@@ -404,6 +404,8 @@ class Tx_Fluid_Core_Parser_TemplateParser {
                $state->setRootNode($rootNode);
                $state->pushNodeToStack($rootNode);
 
+               $state->setVariableContainer($this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer'));
+
                foreach ($splitTemplate as $templateElement) {
                        $matchedVariables = array();
                        if (preg_match(self::$SCAN_PATTERN_CDATA, $templateElement, $matchedVariables) > 0) {
index 8f96a95..03321ca 100644 (file)
@@ -53,7 +53,7 @@ class Tx_Fluid_Core_Rendering_RenderingContext implements Tx_Fluid_Core_Renderin
        /**
         * ViewHelper Variable Container
         *
-        * @var Tx_Fluid_Core_ViewHelpers_ViewHelperVariableContainer
+        * @var Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer
         */
        protected $viewHelperVariableContainer;
 
@@ -65,6 +65,8 @@ class Tx_Fluid_Core_Rendering_RenderingContext implements Tx_Fluid_Core_Renderin
         */
        public function injectObjectManager(Tx_Fluid_Compatibility_ObjectManager $objectManager) {
                $this->objectManager = $objectManager;
+               $this->templateVariableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer');
+               $this->viewHelperVariableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer');
        }
 
        /**
@@ -84,7 +86,7 @@ class Tx_Fluid_Core_Rendering_RenderingContext implements Tx_Fluid_Core_Renderin
         * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer The template variable container to set
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function injectTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
+       public function setTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer) {
                $this->templateVariableContainer = $templateVariableContainer;
        }
 
@@ -125,7 +127,7 @@ class Tx_Fluid_Core_Rendering_RenderingContext implements Tx_Fluid_Core_Renderin
         * @return void
         * @author Sebastian Kurfürst <sebastian@typo3.org>
         */
-       public function injectViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
+       public function setViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer) {
                $this->viewHelperVariableContainer = $viewHelperVariableContainer;
        }
 
index e717c6a..0b0f0e7 100644 (file)
@@ -40,7 +40,7 @@ interface Tx_Fluid_Core_Rendering_RenderingContextInterface {
         *
         * @param Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer The template variable container to set
         */
-       public function injectTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer);
+       public function setTemplateVariableContainer(Tx_Fluid_Core_ViewHelper_TemplateVariableContainer $templateVariableContainer);
 
        /**
         * Get the template variable container
@@ -69,7 +69,7 @@ interface Tx_Fluid_Core_Rendering_RenderingContextInterface {
         * @param Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer
         * @return void
         */
-       public function injectViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer);
+       public function setViewHelperVariableContainer(Tx_Fluid_Core_ViewHelper_ViewHelperVariableContainer $viewHelperVariableContainer);
 
        /**
         * Get the ViewHelperVariableContainer
index e6bdb53..a1bb9b6 100644 (file)
@@ -54,14 +54,12 @@ abstract class Tx_Fluid_Core_ViewHelper_AbstractTagBasedViewHelper extends Tx_Fl
        protected $tagName = 'div';
 
        /**
-        * Inject a TagBuilder
-        *
-        * @param Tx_Fluid_Core_ViewHelper_TagBuilder $tagBuilder Tag builder
+        * @param Tx_Extbase_Object_ObjectManagerInterface $objectManager
         * @return void
-        * @author Bastian Waidelich <bastian@typo3.org>
         */
-       public function injectTagBuilder(Tx_Fluid_Core_ViewHelper_TagBuilder $tagBuilder) {
-               $this->tag = $tagBuilder;
+       public function injectObjectManager(Tx_Extbase_Object_ObjectManagerInterface $objectManager) {
+               $this->objectManager = $objectManager;
+               $this->tag = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TagBuilder');
        }
 
        /**
index bb30af3..cc35582 100644 (file)
@@ -211,7 +211,7 @@ abstract class Tx_Fluid_View_AbstractTemplateView implements Tx_Fluid_View_Templ
                } else {
                        $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
                        $renderingContext = clone $renderingContext;
-                       $renderingContext->injectTemplateVariableContainer($variableContainer);
+                       $renderingContext->setTemplateVariableContainer($variableContainer);
                        $renderingTypeOnNextLevel = $this->getCurrentRenderingType();
                }
 
@@ -240,7 +240,7 @@ abstract class Tx_Fluid_View_AbstractTemplateView implements Tx_Fluid_View_Templ
                $partial = $this->templateParser->parse($this->getPartialSource($partialName));
                $variableContainer = $this->objectManager->create('Tx_Fluid_Core_ViewHelper_TemplateVariableContainer', $variables);
                $renderingContext = clone $this->getCurrentRenderingContext();
-               $renderingContext->injectTemplateVariableContainer($variableContainer);
+               $renderingContext->setTemplateVariableContainer($variableContainer);
 
                $this->startRendering(self::RENDERING_PARTIAL, $partial, $renderingContext);
                if ($sectionName !== NULL) {
index 5ea0cc8..5278afe 100644 (file)
@@ -67,11 +67,10 @@ class Tx_Fluid_ViewHelpers_Format_CropViewHelper extends Tx_Fluid_Core_ViewHelpe
        /**
         * Constructor. Used to create an instance of tslib_cObj used by the render() method.
         *
-        * @param tslib_cObj $contentObject injector for tslib_cObj (optional)
         * @return void
         */
-       public function __construct($contentObject = NULL) {
-               $this->contentObject = $contentObject !== NULL ? $contentObject : t3lib_div::makeInstance('tslib_cObj');
+       public function __construct() {
+               $this->contentObject = t3lib_div::makeInstance('tslib_cObj');
        }
 
        /**