* added a findOne() method to the Repository
authorJochen Rau <j.rau@web.de>
Fri, 20 Feb 2009 09:24:00 +0000 (09:24 +0000)
committerJochen Rau <j.rau@web.de>
Fri, 20 Feb 2009 09:24:00 +0000 (09:24 +0000)
* enhanced Template View (a lot more to do)
* first implementation of the argument mapping (you can say addNewArgument('foo') now)

typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_AbstractController.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ActionController.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Argument.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Arguments.php
typo3/sysext/extbase/Classes/Persistence/TX_EXTMVC_Persistence_Repository.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_TemplateView.php
typo3/sysext/extbase/class.tx_extmvc_dispatcher.php

index c1e6154..b001f2a 100755 (executable)
@@ -22,6 +22,7 @@ declare(ENCODING = 'utf-8');
  *                                                                        */
 
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_ControllerInterface.php');
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_Arguments.php');
 require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Exception/TX_EXTMVC_Exception_StopAction.php');
 
 /**
@@ -58,6 +59,11 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         * @var TX_EXTMVC_Controller_Arguments Arguments passed to the controller
         */
        protected $arguments;
+       
+       /**
+        * @var array An array of allowed property names (or regular expressions matching those)
+        */
+       protected $allowedProperties = array('.*');
 
        /**
         * Constructs the controller.
@@ -67,7 +73,7 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         * @author Robert Lemke <robert@typo3.org>
         */
        public function __construct() {
-               // $this->arguments = $objectFactory->create('TX_EXTMVC_Controller_Arguments');
+               $this->arguments = t3lib_div::makeInstance('TX_EXTMVC_Controller_Arguments');
                list(, $this->extensionKey) = explode('_', strtolower(get_class($this)));
                // debug($this->extensionKey));
                // $this->extension = $packageManager->getPackage($this->extensionKey);
@@ -98,8 +104,8 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
                $this->request->setDispatched(TRUE);
                $this->response = $response;
 
-               // $this->initializeArguments();
-               // $this->mapRequestArgumentsToLocalArguments();
+               $this->initializeArguments();
+               $this->mapRequestArgumentsToLocalArguments();
        }
        
        /**
@@ -180,35 +186,76 @@ abstract class TX_EXTMVC_Controller_AbstractController implements TX_EXTMVC_Cont
         * @author Robert Lemke <robert@typo3.org>
         */
        protected function mapRequestArgumentsToLocalArguments() {
-               $this->propertyMapper->setTarget($this->arguments);
-               foreach ($this->arguments as $argument) {
-                       if ($argument->getFilter() !== NULL) $this->propertyMapper->registerFilter($argument->getFilter(), $argument->getName());
-                       if ($argument->getPropertyConverter() !== NULL) $this->propertyMapper->registerPropertyConverter($argument->getPropertyConverter(), $argument->getName(), $argument->getPropertyConverterInputFormat());
-               }
-
-               $argumentsValidator = t3lib_div::makeInstance('TX_EXTMVC_Controller_ArgumentsValidator', $this->arguments);
-               $this->propertyMapper->registerValidator($argumentsValidator);
-               $this->propertyMapper->setAllowedProperties(array_merge($this->arguments->getArgumentNames(), $this->arguments->getArgumentShortNames()));
-               $this->propertyMapper->map($this->request->getArguments());
+               $this->setAllowedProperties(array_merge($this->arguments->getArgumentNames(), $this->arguments->getArgumentShortNames()));
+               $this->map($this->request->getArguments());
+       }
+       
+       /**
+        * Defines the property names which are allowed for mapping.
+        *
+        * @param  array $allowedProperties: An array of allowed property names. Each entry in this array may be a regular expression.
+        * @return void
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       protected function setAllowedProperties(array $allowedProperties) {
+               $this->allowedProperties = $allowedProperties;
+       }
 
-               $this->argumentMappingResults = $this->propertyMapper->getMappingResults();
+       /**
+        * Returns an array of strings defining the allowed properties for mapping.
+        *
+        * @return array The allowed properties
+        * @author Robert Lemke <robert@typo3.org>
+        */
+       protected function getAllowedProperties() {
+               return $this->allowedProperties;
+       }
+       
+       /**
+        * Checks if the give property is among the allowed properties.
+        *
+        * @param string $propertyName Property name to check for
+        * @return boolean TRUE if the property is allowed, else FALSE
+        * @author Robert Lemke <robert@typo3.org>
+        * @see map()
+        */
+       protected function isAllowedProperty($propertyName) {
+               if (current($this->allowedProperties) === '.*') return TRUE;
 
-               foreach ($this->argumentMappingResults->getErrors() as $propertyName => $error) {
-                       if (isset($this->arguments[$propertyName])) {
-                               $this->arguments[$propertyName]->setValidity(FALSE);
-                               $this->arguments[$propertyName]->addError($error);
+               $isAllowed = FALSE;
+               foreach ($this->allowedProperties as $allowedProperty) {
+                       if (preg_match('/^' . $allowedProperty . '$/', $propertyName) === 1) {
+                               $isAllowed = TRUE;
+                               break;
                        }
                }
-
-               foreach ($this->argumentMappingResults->getWarnings() as $propertyName => $warning) {
-                       if (isset($this->arguments[$propertyName])) $this->arguments[$propertyName]->addWarning($warning);
-               }
-
-               foreach ($this->argumentMappingResults->getUids() as $propertyName => $uid) {
-                       if (isset($this->arguments[$propertyName])) $this->arguments[$propertyName]->setUid($uid);
-               }
+               return $isAllowed;
        }
        
+       /**
+        * Maps the given properties to the target object.
+        * After mapping the results can be retrieved with getMappingResult.
+        *
+        * In case the $target object is directly given to this method, it modifies
+        * the given $target object and the validator and allowedProperties are
+        * reset to their default values.
+        *
+        * @param object $properties Properties to map
+        * @param array $allowedProperties Optional. An array of allowed property names. Each entry in this array may be a regular expression. Will be used instead of this->setAllowedProperties, if it is set.
+        * @return void
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       protected function map($properties, $allowedProperties = NULL) {
+               $getParameters = t3lib_div::_GET();
+               $postParameters = t3lib_div::_POST();
+               foreach ($getParameters as $key => $value) {
+                       if ($this->isAllowedProperty($key)) {
+                               $argument = $this->arguments->getArgument($key);
+                               $argument->setValue($value);
+                       }
+               }
+       }
+
 }
 
 ?>
\ No newline at end of file
index b49b608..7543d6e 100644 (file)
@@ -62,8 +62,8 @@ class TX_EXTMVC_Controller_ActionController extends TX_EXTMVC_Controller_Abstrac
                $this->response = $response;
 
                $this->actionMethodName = $this->resolveActionMethodName();
-               // $this->initializeArguments();
-               // $this->mapRequestArgumentsToLocalArguments();
+               $this->initializeArguments();
+               $this->mapRequestArgumentsToLocalArguments();
                $this->initializeView();
                $this->initializeAction();
 
index 5f15aa6..39f656f 100644 (file)
@@ -28,17 +28,7 @@ declare(ENCODING = 'utf-8');
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class Argument {
-
-       /**
-        * @var F3_FLOW3_Object_ManagerInterface
-        */
-       protected $objectManager;
-
-       /**
-        * @var F3_FLOW3_Object_FactoryInterface
-        */
-       protected $objectFactory;
+class TX_EXTMVC_Controller_Argument {
 
        /**
         * Name of this argument
@@ -70,60 +60,12 @@ class Argument {
         */
        protected $value = NULL;
 
-       /**
-        * Short help message for this argument
-        * @var string Short help message for this argument
-        */
-       protected $shortHelpMessage = NULL;
-
        /**
         * The argument is valid
         * @var boolean
         */
        protected $isValid = TRUE;
 
-       /**
-        * Any error (F3_FLOW3_Error_Error) that occured while initializing this argument (e.g. a mapping error)
-        * @var array
-        */
-       protected $errors = array();
-
-       /**
-        * Any warning (F3_FLOW3_Error_Warning) that occured while initializing this argument (e.g. a mapping warning)
-        * @var array
-        */
-       protected $warnings = array();
-
-       /**
-        * The property validator for this argument
-        * @var F3_FLOW3_Validation_ValidatorInterface
-        */
-       protected $validator = NULL;
-
-       /**
-        * The property validator for this arguments datatype
-        * @var F3_FLOW3_Validation_ValidatorInterface
-        */
-       protected $datatypeValidator = NULL;
-
-       /**
-        * The filter for this argument
-        * @var F3_FLOW3_Validation_FilterInterface
-        */
-       protected $filter = NULL;
-
-       /**
-        * The property converter for this argument
-        * @var F3_FLOW3_Property_ConverterInterface
-        */
-       protected $propertyConverter = NULL;
-
-       /**
-        * The property converter's input format for this argument
-        * @var string
-        */
-       protected $propertyConverterInputFormat = 'string';
-
        /**
         * Uid for the argument, if it has one
         * @var string
@@ -139,12 +81,9 @@ class Argument {
         * @throws InvalidArgumentException if $name is not a string or empty
         * @author Robert Lemke <robert@typo3.org>
         */
-       public function __construct($name, $dataType = 'Text', F3_FLOW3_Object_ManagerInterface $objectManager) {
+       public function __construct($name, $dataType = 'Text') {
                if (!is_string($name) || strlen($name) < 1) throw new InvalidArgumentException('$name must be of type string, ' . gettype($name) . ' given.', 1187951688);
-               $this->objectManager = $objectManager;
-               $this->objectFactory = $this->objectManager->getObjectFactory();
                $this->name = $name;
-
                $this->setDataType($dataType);
        }
 
@@ -191,11 +130,6 @@ class Argument {
         */
        public function setDataType($dataType) {
                $this->dataType = ($dataType != '' ? $dataType : 'Text');
-
-               $dataTypeValidatorClassName = $this->dataType;
-               if (!$this->objectManager->isObjectRegistered($dataTypeValidatorClassName)) $dataTypeValidatorClassName = 'TX_EXTMVC_Validation_Validator_' . $this->dataType;
-               $this->datatypeValidator = $this->objectManager->getObject($dataTypeValidatorClassName);
-
                return $this;
        }
 
@@ -264,30 +198,6 @@ class Argument {
                return $this->value !== NULL;
        }
 
-       /**
-        * Sets a short help message for this argument. Mainly used at the command line, but maybe
-        * used elsewhere, too.
-        *
-        * @param string $message: A short help message
-        * @return TX_EXTMVC_Controller_Argument                $this
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function setShortHelpMessage($message) {
-               if (!is_string($message)) throw new InvalidArgumentException('The help message must be of type string, ' . gettype($message) . 'given.', 1187958170);
-               $this->shortHelpMessage = $message;
-               return $this;
-       }
-
-       /**
-        * Returns the short help message
-        *
-        * @return string The short help message
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function getShortHelpMessage() {
-               return $this->shortHelpMessage;
-       }
-
        /**
         * Set the validity status of the argument
         *
@@ -308,189 +218,7 @@ class Argument {
        public function isValid() {
                return $this->isValid;
        }
-
-       /**
-        * Add an initialization error (e.g. a mapping error)
-        *
-        * @param F3_FLOW3_Error_Error An error object
-        * @return void
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function addError(F3_FLOW3_Error_Error $error) {
-               $this->errors[] = $error;
-       }
-
-       /**
-        * Get all initialization errors
-        *
-        * @return array An array containing F3_FLOW3_Error_Error objects
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        * @see addError(F3_FLOW3_Error_Error $error)
-        */
-       public function getErrors() {
-               return $this->errors;
-       }
-
-       /**
-        * Add an initialization warning (e.g. a mapping warning)
-        *
-        * @param F3_FLOW3_Error_Warning A warning object
-        * @return void
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function addWarning(F3_FLOW3_Error_Warning $warning) {
-               $this->warnings[] = $warning;
-       }
-
-       /**
-        * Get all initialization warnings
-        *
-        * @return array An array containing F3_FLOW3_Error_Warning objects
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        * @see addWarning(F3_FLOW3_Error_Warning $warning)
-        */
-       public function getWarnings() {
-               return $this->warnings;
-       }
-
-       /**
-        * Set an additional validator
-        *
-        * @param string Class name of a validator
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setValidator($className) {
-               $this->validator = $this->objectManager->getObject($className);
-               return $this;
-       }
-
-       /**
-        * Returns the set validator
-        *
-        * @return F3_FLOW3_Validation_ValidatorInterface The set validator, NULL if none was set
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function getValidator() {
-               return $this->validator;
-       }
-
-       /**
-        * Returns the set datatype validator
-        *
-        * @return F3_FLOW3_Validation_ValidatorInterface The set datatype validator
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function getDatatypeValidator() {
-               return $this->datatypeValidator;
-       }
-
-       /**
-        * Set a filter
-        *
-        * @param string Class name of a filter
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setFilter($className) {
-               $this->filter = $this->objectManager->getObject($className);
-               return $this;
-       }
-
-       /**
-        * Create and set a filter chain
-        *
-        * @param array Class names of the filters
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setNewFilterChain(array $classNames) {
-               $this->filter = $this->createNewFilterChainObject();
-
-               foreach ($classNames as $className) {
-                       if (!$this->objectManager->isObjectRegistered($className)) $className = 'F3_FLOW3_Validation_Filter\\' . $className;
-                       $this->filter->addFilter($this->objectManager->getObject($className));
-               }
-
-               return $this;
-       }
-
-       /**
-        * Create and set a validator chain
-        *
-        * @param array Class names of the validators
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setNewValidatorChain(array $classNames) {
-               $this->validator = $this->createNewValidatorChainObject();
-
-               foreach ($classNames as $className) {
-                       if (!$this->objectManager->isObjectRegistered($className)) $className = 'F3_FLOW3_Validation_Validator\\' . $className;
-                       $this->validator->addValidator($this->objectManager->getObject($className));
-               }
-
-               return $this;
-       }
-
-       /**
-        * Returns the set filter
-        *
-        * @return F3_FLOW3_Validation_FilterInterface The set filter, NULL if none was set
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function getFilter() {
-               return $this->filter;
-       }
-
-       /**
-        * Set a property converter
-        *
-        * @param string Class name of a property converter
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setPropertyConverter($className) {
-               if (is_string($className)) {
-                       $this->propertyConverter = t3lib_div::makeInstance($className);
-               } else {
-                       $this->propertyConverter = $className;
-               }
-               return $this;
-       }
-
-       /**
-        * Returns the set property converter
-        *
-        * @return F3_FLOW3_Property_ConverterInterface The set property convertr, NULL if none was set
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function getPropertyConverter() {
-               return $this->propertyConverter;
-       }
-
-       /**
-        * Set a property converter input format
-        *
-        * @param string Input format the property converter should use
-        * @return TX_EXTMVC_Controller_Argument Returns $this (used for fluent interface)
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function setPropertyConverterInputFormat($format) {
-               $this->propertyConverterInputFormat = $format;
-               return $this;
-       }
-
-       /**
-        * Returns the set property converter input format
-        *
-        * @return string The set property converter input format
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function getPropertyConverterInputFormat() {
-               return $this->propertyConverterInputFormat;
-       }
-
+       
        /**
         * Set the uid for the argument.
         *
@@ -512,26 +240,6 @@ class Argument {
                return $this->uid;
        }
 
-       /**
-        * Factory method that creates a new filter chain
-        *
-        * @return F3_FLOW3_Validation_Filter_Chain A new filter chain
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function createNewFilterChainObject() {
-               return t3lib_div::makeInstance('F3_FLOW3_Validation_Filter_Chain');
-       }
-
-       /**
-        * Factory method that creates a new validator chain
-        *
-        * @return F3_FLOW3_Validation_Validator_Chain A new validator chain
-        * @author Andreas Förthner <andreas.foerthner@netlogix.de>
-        */
-       public function createNewValidatorChainObject() {
-               return t3lib_div::makeInstance('F3_FLOW3_Validation_Validator_Chain');
-       }
-
        /**
         * Returns a string representation of this argument's value
         *
index 8f03b25..49314d9 100644 (file)
@@ -21,6 +21,8 @@ declare(ENCODING = 'utf-8');
  * The TYPO3 project - inspiring people to share!                         *
  *                                                                        */
 
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/Controller/TX_EXTMVC_Controller_Argument.php');
+
 /**
  * A composite of controller arguments
  *
@@ -28,36 +30,13 @@ declare(ENCODING = 'utf-8');
  * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
  * @scope prototype
  */
-class Arguments extends ArrayObject {
-
-       /**
-        * @var F3_FLOW3_Object_FactoryInterface A reference to the object factory
-        */
-       protected $objectFactory;
-
-       /**
-        * @var F3_FLOW3_Object_ManagerInterface A reference to the object manager
-        */
-       protected $objectManager;
+class TX_EXTMVC_Controller_Arguments extends ArrayObject {
 
        /**
         * @var array Names of the arguments contained by this object
         */
        protected $argumentNames = array();
 
-       /**
-        * Constructs this Arguments object
-        *
-        * @param F3_FLOW3_Object_FactoryInterface $objectFactory
-        * @param F3_FLOW3_Object_ManagerInterface $objectManager
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function __construct(F3_FLOW3_Object_FactoryInterface $objectFactory, F3_FLOW3_Object_ManagerInterface $objectManager) {
-               $this->objectFactory = $objectFactory;
-               $this->objectManager = $objectManager;
-               parent::__construct();
-       }
-
        /**
         * Adds or replaces the argument specified by $value. The argument's name is taken from the
         * argument object itself, therefore the $offset does not have any meaning in this context.
@@ -147,13 +126,9 @@ class Arguments extends ArrayObject {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function addNewArgument($name, $dataType = 'Text', $isRequired = FALSE) {
-               $argument = t3lib_div::makeInstance('TX_EXTMVC_Controller_Argument', $name, $dataType);
+               $argumentClassName = t3lib_div::makeInstanceClassName('TX_EXTMVC_Controller_Argument');
+               $argument = new $argumentClassName($name, $dataType);
                $argument->setRequired($isRequired);
-
-               if ($this->objectManager->isObjectRegistered($dataType)) {
-                       $propertyConverter = t3lib_div::makeInstance('F3_FLOW3_Property_Converter_DomainObjectConverter', $dataType);
-                       $argument->setPropertyConverter($propertyConverter)->setPropertyConverterInputFormat('array');
-               }
                $this->addArgument($argument);
                return $argument;
        }
index 9eeaaee..57b6d99 100644 (file)
@@ -58,11 +58,11 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
        protected $session;
 
        /**
-        * Holds an array of allowed properties to be called via magig findBy methods
+        * Holds an array of blacklisted properties not to be called via magic findBy methods
         *
         * @var array
         */
-       protected $allowedFindByProperties = array();
+       protected $blacklistedFindByProperties = array('passwd', 'password');
        
        /**
         * The content object
@@ -86,7 +86,7 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
                $this->dataMapper = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Mapper_ObjectRelationalMapper'); // singleton
                $this->session = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Session'); // singleton
                $this->session->registerAggregateRootClassName($this->aggregateRootClassName);
-               // FIXIT auto resolve findBy properties
+               // FIXIT auto resolve findBy properties; black list
                $this->allowedFindByProperties = array('name', 'blog');
        }
        
@@ -152,17 +152,17 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
        public function __call($methodName, $arguments) {
                if (substr($methodName, 0, 6) === 'findBy') {
                        $propertyName = TX_EXTMVC_Utility_Strings::lowercaseFirst(substr($methodName,6));
-                       if (in_array($propertyName, $this->allowedFindByProperties)) {
+                       if (!in_array($propertyName, $this->blacklistedFindByProperties)) {
                                return $this->findByProperty($propertyName, $arguments[0]);
                        }
                } elseif (substr($methodName, 0, 9) === 'findOneBy') {
                        $propertyName = TX_EXTMVC_Utility_Strings::lowercaseFirst(substr($methodName,9));
-                       if (in_array($propertyName, $this->allowedFindByProperties)) {
+                       if (!in_array($propertyName, $this->blacklistedFindByProperties)) {
                                $result = $this->findByProperty($propertyName, $arguments[0]);
                                if (empty($result)) {
                                        return FALSE;
                                } else {
-                                       return $result[0];
+                                       return $result[0]; // TODO LIMIT
                                }
                        }
                }
@@ -180,6 +180,18 @@ class TX_EXTMVC_Persistence_Repository implements TX_EXTMVC_Persistence_Reposito
                return $this->dataMapper->findWhere($this->aggregateRootClassName);
        }
        
+       /**
+        * Returns the first objects found in this repository
+        *
+        * @return TX_EXTMVC_DomainObject_AbstractDomainObject A single object, empty if no objects found
+        * @author Jochen Rau <jochen.rau@typoplanet.de>
+        */
+       public function findOne() {
+               // TODO implement support for SQL LIMIT
+               $result = $this->dataMapper->findWhere($this->aggregateRootClassName);
+               return $result[0];
+       }
+       
        /**
         * Finds objects matching 'property=xyz'
         *
index b41320a..f8c4a07 100644 (file)
@@ -220,30 +220,18 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                        $result = $this->translate(strtolower($markerContent));
                }
                // FIXME
-               $explodedMarkerName = explode('.', $markerName);
-               if ($value === NULL) {
-                       if (!empty($this->contextVariables[strtolower($markerName)])) {
-                               $result = $this->contextVariables[strtolower($markerName)];
-                       }
-               } elseif (count($explodedMarkerName) == 2 && $value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
-                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedMarkerName[1]);
-                       if (method_exists($value, $possibleMethodName)) {
-                               $result = $value->$possibleMethodName();
-                       }
-               } else {
-               }
-               return $this->convertValue($result);
+               return $this->getValueForMarker($markerName, $value);
        }
        
        protected function getSubpartArray($templateName, $templateSource, $value) {
                $subparts = $this->getSubparts($templateSource);
                $subpartArray = array();
                if (count($subparts) > 0) {
-                       foreach ($subparts as $subpartName => $subpartTemplateSource) {
-                               $value = $this->getValueForSubpart($subpartName, $value);
+                       foreach ($subparts as $subpartMarker => $subpartTemplateSource) {
+                               $value = $this->getValueForMarker($subpartMarker, $value);
                                if (is_array($value) || ($value instanceof ArrayObject)) {
                                        foreach ($value as $key => $innerValue) {
-                                               $subpartArray['###' . $subpartName . '###'] .= $this->renderTemplate($subpartName, $subpartTemplateSource, $innerValue);
+                                               $subpartArray['###' . $subpartMarker . '###'] .= $this->renderTemplate($subpartName, $subpartTemplateSource, $innerValue);
                                        }
                                }
                        }
@@ -251,20 +239,19 @@ class TX_EXTMVC_View_TemplateView extends TX_EXTMVC_View_AbstractView {
                return $subpartArray;
        }
        
-       protected function getValueForSubpart($subpartName, $value) {
+       protected function getValueForMarker($markerName, $value) {
+               $explodedMarkerName = explode('.', $markerName);
                if ($value === NULL) {
-                       if (!empty($this->contextVariables[strtolower($subpartName)])) {
-                               $result = $this->contextVariables[strtolower($subpartName)];
-                       }
-               } elseif ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
-                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($subpartName);
+                               $value = $this->contextVariables[strtolower($explodedMarkerName[0])];
+               }
+               if ($value instanceof TX_EXTMVC_DomainObject_AbstractDomainObject) {
+                       $possibleMethodName = 'get' . TX_EXTMVC_Utility_Strings::underscoredToUpperCamelCase($explodedMarkerName[1]);
                        if (method_exists($value, $possibleMethodName)) {
                                $result = $value->$possibleMethodName();
                        }
                } else {
                        $result = $value;
                }
-               
                return $this->convertValue($result);
        }
        
index f6a4acd..c8fbb2a 100644 (file)
@@ -100,8 +100,6 @@ class TX_EXTMVC_Dispatcher {
                $controller = t3lib_div::makeInstance($controllerObjectName);
                
                if (!$controller instanceof TX_EXTMVC_Controller_AbstractController) throw new TX_EXTMVC_Exception_InvalidController('Invalid controller "' . $controllerObjectName . '". The controller must be a valid request handling controller.', 1202921619);
-               // $getParameters = t3lib_div::_GET();
-               // $postParameters = t3lib_div::_POST();
                // $settings = $this->configurationManager->getSettings($extensionKey);
                // $controller->injectSettings($this->configurationManager->getSettings($request->getControllerExtensionKey()));
                $session = t3lib_div::makeInstance('TX_EXTMVC_Persistence_Session');