Changeset 7674

Show
Ignore:
Timestamp:
06/24/09 03:27:05 (9 months ago)
Author:
inureyes
Message:

refs #777

  • Singleton class를 coreclasses 에서 취급 (trunk처럼)
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/1.8/framework/boot/10-CoreClasses.php

    r7672 r7674  
    33/// All rights reserved. Licensed under the GPL. 
    44/// See the GNU General Public License for more details. (/doc/LICENSE, /doc/COPYRIGHT) 
     5 
     6/// Singleton implementation. 
     7abstract class Singleton { 
     8    private static $instances = array(); 
     9 
     10    protected function __construct() { 
     11    } 
     12 
     13    final protected static function _getInstance($className) { 
     14        if (!array_key_exists($className, self::$instances)) { 
     15            self::$instances[$className] = new $className(); 
     16        } 
     17        return self::$instances[$className]; 
     18    } 
     19 
     20    /* 
     21    // You should implement this method to the final class. (An example is below.) 
     22    // This is mainly because "late static bindings" is supported after PHP 5.3. 
     23 
     24    public static function getInstance() { 
     25        return self::_getInstance(__CLASS__); 
     26    } 
     27    */ 
     28    abstract public static function getInstance(); 
     29} 
     30 
    531final class String { 
    632    static function endsWith($string, $end) {