Resolves #60725: Reduce used memory of the Domain Models (Thanks to Tim Lochmüller)
authorstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 22 Sep 2014 16:11:44 +0000 (16:11 +0000)
committerstan <stan@735d13b6-9817-0410-8766-e36946ffe9aa>
Mon, 22 Sep 2014 16:11:44 +0000 (16:11 +0000)
git-svn-id: https://svn.typo3.org/TYPO3v4/Extensions/static_info_tables/trunk@86390 735d13b6-9817-0410-8766-e36946ffe9aa

ChangeLog
Classes/Domain/Model/AbstractEntity.php
Classes/Domain/Model/Country.php
Classes/Domain/Model/CountryZone.php
Classes/Domain/Model/Currency.php
Classes/Domain/Model/Language.php
Classes/Domain/Model/Territory.php
Classes/Utility/ModelUtility.php [new file with mode: 0644]

index 9cf4e03..a545788 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -3,6 +3,7 @@
        * Resolves #59586: Add Subterritory "419 Latin America and the Caribbean"
        * Resolves #61769: Polish zones should be written beginning from lower letter
        * Rename directory Configuration/Tca to Configuration/TCA
+       * Resolves #60725: Reduce used memory of the Domain Models (Thanks to Tim Lochmüller)
 
 2014-07-29  Stanislas Rolland  <typo3@sjbr.ca>
 
index 4d56ca3..9d3d4f1 100644 (file)
@@ -1,10 +1,9 @@
 <?php
 namespace SJBR\StaticInfoTables\Domain\Model;
-use \SJBR\StaticInfoTables\Utility\LocalizationUtility;
 /***************************************************************
 *  Copyright notice
 *
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -26,18 +25,11 @@ use \SJBR\StaticInfoTables\Utility\LocalizationUtility;
 ***************************************************************/
 /**
  * Abstract model for static entities
- *
- * @copyright Copyright belongs to the respective authors
- * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
-class AbstractEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
 
-       /**
-        * Extbase configuration
-        *
-        * @var array
-        */
-       protected $extbaseConfiguration;
+use \SJBR\StaticInfoTables\Utility\LocalizationUtility;
+
+class AbstractEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
 
        /**
         * Name of the table from persistence mapping of this model
@@ -63,8 +55,6 @@ class AbstractEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
         */
        public function initializeObject() {
                $this->objectManager = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
-               $configurationManager = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
-               $this->extbaseConfiguration = $configurationManager->getConfiguration(\TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
        }
 
        /**
@@ -103,5 +93,4 @@ class AbstractEntity extends \TYPO3\CMS\Extbase\DomainObject\AbstractEntity {
                }
                return $this->nameLocalized;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 31f7c1b..5b1dd96 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Domain\Model;
 *  Copyright notice
 *
 *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -30,6 +30,9 @@ namespace SJBR\StaticInfoTables\Domain\Model;
  * @copyright Copyright belongs to the respective authors
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
+
+use SJBR\StaticInfoTables\Utility\ModelUtility;
+
 class Country extends AbstractEntity {
        /**
         * @var string
@@ -152,8 +155,8 @@ class Country extends AbstractEntity {
         */
        public function initializeObject() {
                parent::initializeObject();
-               $this->tableName = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Country']['mapping']['tableName'];
-               $this->columnsMapping = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Country']['mapping']['columns'];
+               $this->tableName = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Country', ModelUtility::MAPPING_TABLENAME);
+               $this->columnsMapping = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Country', ModelUtility::MAPPING_COLUMNS);
                $this->countryZones = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\ObjectStorage');
        }
 
@@ -557,5 +560,4 @@ class Country extends AbstractEntity {
        public function getCountryZones() {
                return $this->countryZones;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index bf38806..61837c4 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Domain\Model;
 *  Copyright notice
 *
 *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -30,6 +30,9 @@ namespace SJBR\StaticInfoTables\Domain\Model;
  * @copyright Copyright belongs to the respective authors
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
+
+use SJBR\StaticInfoTables\Utility\ModelUtility;
+
 class CountryZone extends AbstractEntity {
        /**
         * Country code as two digit string (i.e. AT)
@@ -82,8 +85,8 @@ class CountryZone extends AbstractEntity {
         */
        public function initializeObject() {
                parent::initializeObject();
-               $this->tableName = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\CountryZone']['mapping']['tableName'];
-               $this->columnsMapping = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\CountryZone']['mapping']['columns'];
+               $this->tableName = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\CountryZone', ModelUtility::MAPPING_TABLENAME);
+               $this->columnsMapping = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\CountryZone', ModelUtility::MAPPING_COLUMNS);
        }
 
        /**
@@ -227,5 +230,4 @@ class CountryZone extends AbstractEntity {
                }
                return $this->nameEn;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 7d93864..e85f316 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Domain\Model;
 *  Copyright notice
 *
 *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -30,6 +30,9 @@ namespace SJBR\StaticInfoTables\Domain\Model;
  * @copyright Copyright belongs to the respective authors
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
+
+use SJBR\StaticInfoTables\Utility\ModelUtility;
+
 class Currency extends AbstractEntity {
 
        /**
@@ -117,8 +120,8 @@ class Currency extends AbstractEntity {
         */
        public function initializeObject() {
                parent::initializeObject();
-               $this->tableName = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Currency']['mapping']['tableName'];
-               $this->columnsMapping = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Currency']['mapping']['columns'];
+               $this->tableName = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Currency', ModelUtility::MAPPING_TABLENAME);
+               $this->columnsMapping = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Currency', ModelUtility::MAPPING_COLUMNS);
        }
 
        /**
@@ -379,5 +382,4 @@ class Currency extends AbstractEntity {
        public function getThousandsPoint() {
                return $this->thousandsPoint;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index c620f87..b33b01f 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Domain\Model;
 *  Copyright notice
 *
 *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -31,6 +31,9 @@ namespace SJBR\StaticInfoTables\Domain\Model;
  * @copyright Copyright belongs to the respective authors
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
+
+use SJBR\StaticInfoTables\Utility\ModelUtility;
+
 class Language extends AbstractEntity {
        /**
         * @var string
@@ -90,8 +93,8 @@ class Language extends AbstractEntity {
         */
        public function initializeObject() {
                parent::initializeObject();
-               $this->tableName = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Language']['mapping']['tableName'];
-               $this->columnsMapping = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Language']['mapping']['columns'];
+               $this->tableName = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Language', ModelUtility::MAPPING_TABLENAME);
+               $this->columnsMapping = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Language', ModelUtility::MAPPING_COLUMNS);
        }
 
        /**
@@ -294,5 +297,4 @@ class Language extends AbstractEntity {
        public function getTypo3Code() {
                return $this->typo3Code;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
index 124e25b..1c9ce93 100644 (file)
@@ -4,7 +4,7 @@ namespace SJBR\StaticInfoTables\Domain\Model;
 *  Copyright notice
 *
 *  (c) 2011-2012 Armin Rüdiger Vieweg <info@professorweb.de>
-*  (c) 2013 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*  (c) 2013-2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
 *
 *  All rights reserved
 *
@@ -31,6 +31,9 @@ namespace SJBR\StaticInfoTables\Domain\Model;
  * @copyright Copyright belongs to the respective authors
  * @license http://www.gnu.org/licenses/gpl.html GNU General Public License, version 3 or later
  */
+
+use SJBR\StaticInfoTables\Utility\ModelUtility;
+
 class Territory extends AbstractEntity {
 
        /**
@@ -62,8 +65,8 @@ class Territory extends AbstractEntity {
         */
        public function initializeObject() {
                parent::initializeObject();
-               $this->tableName = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Territory']['mapping']['tableName'];
-               $this->columnsMapping = $this->extbaseConfiguration['persistence']['classes']['SJBR\\StaticInfoTables\\Domain\\Model\\Territory']['mapping']['columns'];
+               $this->tableName = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Territory', ModelUtility::MAPPING_TABLENAME);
+               $this->columnsMapping = ModelUtility::getModelMapping('SJBR\\StaticInfoTables\\Domain\\Model\\Territory', ModelUtility::MAPPING_COLUMNS);
        }
 
        /**
@@ -144,5 +147,4 @@ class Territory extends AbstractEntity {
        public function getParentTerritoryUnCodeNumber() {
                return $this->parentTerritoryUnCodeNumber;
        }
-}
-?>
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/Classes/Utility/ModelUtility.php b/Classes/Utility/ModelUtility.php
new file mode 100644 (file)
index 0000000..85cf878
--- /dev/null
@@ -0,0 +1,70 @@
+<?php
+namespace SJBR\StaticInfoTables\Utility;
+/***************************************************************
+*  Copyright notice
+*
+*  (c) 2014 Tim Lochmüller <tim.lochmueller@hdnet.de>
+*  (c) 2014 Stanislas Rolland <typo3(arobas)sjbr.ca>
+*
+*  All rights reserved
+*
+*  This script is part of the TYPO3 project. The TYPO3 project is
+*  free software; you can redistribute it and/or modify
+*  it under the terms of the GNU General Public License as published by
+*  the Free Software Foundation; either version 2 of the License, or
+*  (at your option) any later version.
+*
+*  The GNU General Public License can be found at
+*  http://www.gnu.org/copyleft/gpl.html.
+*
+*  This script is distributed in the hope that it will be useful,
+*  but WITHOUT ANY WARRANTY; without even the implied warranty of
+*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+*  GNU General Public License for more details.
+*
+*  This copyright notice MUST APPEAR in all copies of the script!
+***************************************************************/
+/**
+ * Utility functions used by the domain models
+ */
+
+use TYPO3\CMS\Core\Utility\GeneralUtility;
+use TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface;
+
+class ModelUtility {
+
+       /**
+        * Internal Extbase configuration
+        *
+        * @var array
+        */
+       private static $extbaseConfiguration = NULL;
+
+       /**
+        * Mapping for the table name
+        */
+       const MAPPING_TABLENAME = 'tableName';
+
+       /**
+        * Mapping for the columns
+        */
+       const MAPPING_COLUMNS = 'columns';
+
+       /**
+        * Get the table mapping from the Extbase configuration
+        *
+        * @param string $modelName
+        * @param string $configurationType
+        * @return string
+        */
+       static public function getModelMapping($modelName, $mappingType) {
+               if (self::$extbaseConfiguration === NULL) {
+                       /** @var \TYPO3\CMS\Extbase\Object\ObjectManager $objectManager */
+                       $objectManager = GeneralUtility::makeInstance('TYPO3\\CMS\\Extbase\\Object\\ObjectManager');
+                       /** @var \TYPO3\CMS\Extbase\Configuration\ConfigurationManager $configurationManager */
+                       $configurationManager = $objectManager->get('TYPO3\\CMS\\Extbase\\Configuration\\ConfigurationManager');
+                       self::$extbaseConfiguration = $configurationManager->getConfiguration(ConfigurationManagerInterface::CONFIGURATION_TYPE_FRAMEWORK);
+               }
+               return self::$extbaseConfiguration['persistence']['classes'][$modelName]['mapping'][$mappingType] ? : NULL;
+       }
+}
\ No newline at end of file