* Added AbstractDomainObject, AbstractEntityObject, and AbstractValueObject
authorJochen Rau <j.rau@web.de>
Mon, 26 Jan 2009 14:32:25 +0000 (14:32 +0000)
committerJochen Rau <j.rau@web.de>
Mon, 26 Jan 2009 14:32:25 +0000 (14:32 +0000)
* Enhanced TemplateView to auto render domain object (not yet finished)

13 files changed:
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Argument.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_Arguments.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_ArgumentsValidator.php
typo3/sysext/extbase/Classes/Controller/TX_EXTMVC_Controller_RequestHandlingController.php
typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateResource.php [deleted file]
typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateSource.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractEntityObject.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractValueObject.php [new file with mode: 0644]
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_AbstractView.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_DefaultView.php
typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_Template.php [deleted file]
typo3/sysext/extbase/Classes/Web/TX_EXTMVC_Web_RequestHandler.php

index 91645a4..cc24228 100644 (file)
@@ -452,7 +452,7 @@ class Argument {
         */
        public function setPropertyConverter($className) {
                if (is_string($className)) {
-                       $this->propertyConverter = $this->objectFactory->create($className);
+                       $this->propertyConverter = t3lib_div::makeInstance($className);
                } else {
                        $this->propertyConverter = $className;
                }
@@ -519,7 +519,7 @@ class Argument {
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
        public function createNewFilterChainObject() {
-               return $this->objectFactory->create('F3_FLOW3_Validation_Filter_Chain');
+               return t3lib_div::makeInstance('F3_FLOW3_Validation_Filter_Chain');
        }
 
        /**
@@ -529,7 +529,7 @@ class Argument {
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
        public function createNewValidatorChainObject() {
-               return $this->objectFactory->create('F3_FLOW3_Validation_Validator_Chain');
+               return t3lib_div::makeInstance('F3_FLOW3_Validation_Validator_Chain');
        }
 
        /**
index 256ef90..8f03b25 100644 (file)
@@ -147,11 +147,11 @@ class Arguments extends ArrayObject {
         * @author Robert Lemke <robert@typo3.org>
         */
        public function addNewArgument($name, $dataType = 'Text', $isRequired = FALSE) {
-               $argument = $this->objectFactory->create('TX_EXTMVC_Controller_Argument', $name, $dataType);
+               $argument = t3lib_div::makeInstance('TX_EXTMVC_Controller_Argument', $name, $dataType);
                $argument->setRequired($isRequired);
 
                if ($this->objectManager->isObjectRegistered($dataType)) {
-                       $propertyConverter = $this->objectFactory->create('F3_FLOW3_Property_Converter_DomainObjectConverter', $dataType);
+                       $propertyConverter = t3lib_div::makeInstance('F3_FLOW3_Property_Converter_DomainObjectConverter', $dataType);
                        $argument->setPropertyConverter($propertyConverter)->setPropertyConverterInputFormat('array');
                }
                $this->addArgument($argument);
index 8c2f969..26eaf9d 100644 (file)
@@ -138,7 +138,7 @@ class ArgumentsValidator implements F3_FLOW3_Validation_ObjectValidatorInterface
         * @author Andreas Förthner <andreas.foerthner@netlogix.de>
         */
        protected function createNewValidationErrorsObject() {
-               return $this->objectFactory->create('F3_FLOW3_Validation_Errors');
+               return t3lib_div::makeInstance('F3_FLOW3_Validation_Errors');
        }
 }
 ?>
\ No newline at end of file
index 02a7c0b..695d498 100644 (file)
@@ -218,7 +218,7 @@ class TX_EXTMVC_Controller_RequestHandlingController extends TX_EXTMVC_Controlle
                        if ($argument->getPropertyConverter() != NULL) $this->propertyMapper->registerPropertyConverter($argument->getPropertyConverter(), $argument->getName(), $argument->getPropertyConverterInputFormat());
                }
 
-               $argumentsValidator = $this->objectFactory->create('TX_EXTMVC_Controller_ArgumentsValidator', $this->arguments);
+               $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());
diff --git a/typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateResource.php b/typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateResource.php
deleted file mode 100644 (file)
index e87690e..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * An "Invalid Template Resource" exception
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- */
-class InvalidTemplateResource extends TX_EXTMVC_Exception {
-
-}
-
-?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateSource.php b/typo3/sysext/extbase/Classes/Exception/TX_EXTMVC_Exception_InvalidTemplateSource.php
new file mode 100644 (file)
index 0000000..91b07ac
--- /dev/null
@@ -0,0 +1,34 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * An "Invalid Template Resource" exception
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+class InvalidTemplateSource extends TX_EXTMVC_Exception {
+
+}
+
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractDomainObject.php
new file mode 100644 (file)
index 0000000..df99898
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * A generic Domain Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_AbstractDomainObject {
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractEntityObject.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractEntityObject.php
new file mode 100644 (file)
index 0000000..984a312
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
+
+/**
+ * A generic Entity Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_AbstractEntityObject extends TX_EXTMVC_AbstractDomainObject {
+
+}
+?>
\ No newline at end of file
diff --git a/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractValueObject.php b/typo3/sysext/extbase/Classes/TX_EXTMVC_AbstractValueObject.php
new file mode 100644 (file)
index 0000000..c15bafd
--- /dev/null
@@ -0,0 +1,35 @@
+<?php
+declare(ENCODING = 'utf-8');
+
+/*                                                                        *
+ * This script belongs to the FLOW3 framework.                            *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+require_once(t3lib_extMgm::extPath('extmvc') . 'Classes/TX_EXTMVC_AbstractDomainObject.php');
+
+/**
+ * A generic Value Object
+ *
+ * @version $Id:$
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ */
+abstract class TX_EXTMVC_AbstractValueObject extends TX_EXTMVC_AbstractDomainObject {
+
+}
+?>
\ No newline at end of file
index 4f8ced9..aea3cdc 100755 (executable)
@@ -44,7 +44,7 @@ abstract class TX_EXTMVC_View_AbstractView implements TX_EXTMVC_ViewInterface {
        /**
         * @var array
         */
-       protected $model;
+       protected $contextVariables = array();
 
        /**
         * Constructs the view.
@@ -110,8 +110,8 @@ abstract class TX_EXTMVC_View_AbstractView implements TX_EXTMVC_ViewInterface {
         * @param mixed $value the value to assign
         * @return void
         */
-       public function assign($name, $value) {
-               $this->model[$name] = $value;
+       public function assign($key, $value) {
+               $this->contextVariables[strtolower($key)] = $value;
        }
 
 }
index 1f361bf..8b5bc2f 100755 (executable)
@@ -44,7 +44,7 @@ class TX_EXTMVC_View_DefaultView extends TX_EXTMVC_View_AbstractView {
        public function render() {
                if (!is_object($this->request)) throw new TX_EXTMVC_Exception('Can\'t render view without request object.', 1192450280);
 
-               $template = $this->objectFactory->create('TX_EXTMVC_View_Template');
+               $template = t3lib_div::makeInstance('TX_EXTMVC_View_TemplateView');
                $template->setTemplateResource($this->resourceManager->getResource('file://FLOW3/Public/MVC/DefaultView_Template.html')->getContent());
 
                if ($this->request instanceof TX_EXTMVC_Web_Request) {
diff --git a/typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_Template.php b/typo3/sysext/extbase/Classes/View/TX_EXTMVC_View_Template.php
deleted file mode 100644 (file)
index d299632..0000000
+++ /dev/null
@@ -1,123 +0,0 @@
-<?php
-declare(ENCODING = 'utf-8');
-
-/*                                                                        *
- * This script belongs to the FLOW3 framework.                            *
- *                                                                        *
- * It is free software; you can redistribute it and/or modify it under    *
- * the terms of the GNU Lesser General Public License as published by the *
- * Free Software Foundation, either version 3 of the License, or (at your *
- * option) any later version.                                             *
- *                                                                        *
- * This script is distributed in the hope that it will be useful, but     *
- * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
- * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
- * General Public License for more details.                               *
- *                                                                        *
- * You should have received a copy of the GNU Lesser General Public       *
- * License along with the script.                                         *
- * If not, see http://www.gnu.org/licenses/lgpl.html                      *
- *                                                                        *
- * The TYPO3 project - inspiring people to share!                         *
- *                                                                        */
-
-/**
- * A basic Template View
- *
- * @version $Id:$
- * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
- * @scope prototype
- */
-class TX_EXTMVC_View_Template extends TX_EXTMVC_View_AbstractView {
-
-       /**
-        * @var string
-        */
-       protected $templateResource;
-
-       /**
-        * @var array Marker identifiers and their replacement content
-        */
-       protected $markers = array();
-
-       /**
-        * @var array Parts
-        */
-       protected $parts = array();
-
-       /**
-        * Sets the text resource which contains the markers this template view
-        * is going to fill in. Relative to the Resources folder.
-        *
-        * @param string $template The template
-        * @return void
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function setTemplateResource($templateResource) {
-               $this->templateResource = $templateResource;
-       }
-
-       /**
-        * Sets the content of a marker. All markers with this name will be
-        * replaced by the content when this template is rendered.
-        *
-        * @param string $marker The marker which will be replaced by $content
-        * @param string $content The fill-in for the specified marker
-        * @return void
-        * @throws TX_EXTMVC_Exception_InvalidMarker if the marker is not a valid string
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function setMarkerContent($marker, $content) {
-               if (!is_string($marker)) throw new TX_EXTMVC_Exception_InvalidMarker('A template marker must be a valid string, ' . gettype($marker) . ' given.', 1187334295);
-               $this->markers[$marker] = $content;
-       }
-
-       /**
-        * Sets the content of a part. All parts which are enclosed by markers
-        * with this name will be replaced by the content when this template
-        * is rendered.
-        *
-        * @param string $partMarker Marker which identifies the part
-        * @param string $content The fill-in for the specified part
-        * @return void
-        * @throws TX_EXTMVC_Exception_InvalidPart if the part marker is not a valid string
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function setPartContent($partMarker, $content) {
-               if (!is_string($partMarker)) throw new TX_EXTMVC_Exception_InvalidPart('A template part marker must be a valid string, ' . gettype($partMarker) . ' given.', 1187334296);
-               $this->parts[$partMarker] = $content;
-       }
-
-       /**
-        * Renders this template view.
-        *
-        * @return string The rendered template view
-        * @throws TX_EXTMVC_Exception_InvalidTemplateResource if no template resource has been defined yet
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       public function render() {
-               if ($this->templateResource == '') throw new TX_EXTMVC_Exception_InvalidTemplateResource('No template resource has been defined yet.', 1187860750);
-               $output = $this->templateResource;
-               foreach ($this->markers as $marker => $content) {
-                       $output = str_replace('###' . strtoupper($marker) . '###', $content, $output);
-               }
-
-               foreach ($this->parts as $marker => $content) {
-                       $output = preg_replace('/<!--\s*###' . strtoupper(preg_quote($marker, '/')) . '###.*###' . strtoupper(preg_quote($marker, '/')) . '###.*-->/msU', $content, $output);
-               }
-               return $output;
-       }
-
-       /**
-        * Substitutes a subpart in $content with the content of $subpartContent.
-        *
-        * @param string Content with subpart wrapped in fx. "###CONTENT_PART###" inside.
-        * @param string Marker string, eg. "###CONTENT_PART###"
-        * @param array
-        * @return string Processed input content
-        * @author Robert Lemke <robert@typo3.org>
-        */
-       protected function substitutePart($subject, $marker, $replacement) {
-       }
-}
-?>
\ No newline at end of file
index 220cd5e..3968fc3 100755 (executable)
@@ -87,7 +87,7 @@ class RequestHandler implements TX_EXTMVC_RequestHandlerInterface {
        public function handleRequest() {
                $request = $this->requestBuilder->build();
                $this->requestProcessorChainManager->processRequest($request);
-               $response = $this->objectFactory->create('TX_EXTMVC_Web_Response');
+               $response = t3lib_div::makeInstance('TX_EXTMVC_Web_Response');
                $this->dispatcher->dispatch($request, $response);
                $response->send();
        }