Index: t3lib/class.t3lib_div.php =================================================================== --- t3lib/class.t3lib_div.php (revision 4298) +++ t3lib/class.t3lib_div.php (working copy) @@ -4608,6 +4608,8 @@ * @return object A reference to the object */ public static function &makeInstance($className) { + // holds references of singletons + static $instances = array(); // Load class file if not found: if (!class_exists($className)) { @@ -4619,8 +4621,16 @@ // Get final classname $className = t3lib_div::makeInstanceClassName($className); + if (isset($instances[$className])) { + return $instances[$className]; + } + $instance = new $className; + if ($instance instanceof t3lib_singleton) { + $instances[$className] = $instance; + } + // Return object. - return new $className; + return $instance; } /** Index: t3lib/interfaces/interface.t3lib_singleton.php =================================================================== --- t3lib/interfaces/interface.t3lib_singleton.php (revision 0) +++ t3lib/interfaces/interface.t3lib_singleton.php (revision 0) @@ -0,0 +1,40 @@ + +* 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. +* A copy is found in the textfile GPL.txt and important notices to the license +* from the author is found in LICENSE.txt distributed with these scripts. +* +* +* 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! +***************************************************************/ + +/** + * dummy interface for singletons (marker interface pattern) + * + * @author Martin Kutschker + * @package TYPO3 + * @subpackage t3lib + * @see t3lib_div::makeInstance() + */ +interface t3lib_singleton { + // deliberately empty +} + +?>\ No newline at end of file