Public paste
illi boot-loader
By: fruffl | Date: Jan 16 2010 21:13 | Format: PHP | Expires: never | Size: 7.48 KB | Hits: 912

  1. <?php
  2.  
  3.        
  4.        
  5.         FINAL CLASS ILLI_BootSubSection_Exception EXTENDS ILLI_Exception{}
  6.        
  7.         ABSTRACT CLASS ILLI_BootSubSection
  8.         {
  9.                 final private function __clone() {}            
  10.                 abstract protected function init();            
  11.         }
  12.        
  13.         ABSTRACT CLASS ILLI_BootSubSection_System EXTENDS ILLI_BootSubSection
  14.         {
  15.                 final public function __construct(ILLI_BootSection_System $ILLI_BootSection_System)
  16.                         {return $this->init();}
  17.         }
  18.        
  19.         FINAL CLASS ILLI_BootSubSection_SystemErrors EXTENDS ILLI_BootSubSection_System
  20.         {
  21.                 protected function init()
  22.                 {
  23.                         return $this;
  24.                 }
  25.         }
  26.        
  27.         FINAL CLASS ILLI_BootSubSection_SystemRequirements EXTENDS ILLI_BootSubSection_System
  28.         {
  29.                 protected function init()
  30.                 {
  31.                         return $this;
  32.                 }
  33.         }
  34.        
  35.         FINAL CLASS ILLI_BootSubSection_SystemRegistry EXTENDS ILLI_BootSubSection_System
  36.         {
  37.                 protected function init()
  38.                 {
  39.                         return $this;
  40.                 }
  41.         }      
  42.        
  43.         ABSTRACT CLASS ILLI_BootSubSection_Settings EXTENDS ILLI_BootSubSection
  44.         {
  45.                 final public function __construct(ILLI_BootSection_Settings $ILLI_BootSection_System)
  46.                         {return $this->init();}
  47.         }
  48.        
  49.        
  50.         FINAL CLASS ILLI_BootSubSection_SettingsCore EXTENDS ILLI_BootSubSection_System
  51.         {
  52.                 protected function init()
  53.                 {
  54.                         return $this;
  55.                 }
  56.         }
  57.        
  58.         FINAL CLASS ILLI_BootSubSection_SettingsApplication EXTENDS ILLI_BootSubSection_System
  59.         {
  60.                 protected function init()
  61.                 {
  62.                         return $this;
  63.                 }
  64.         }
  65.        
  66.         ABSTRACT CLASS ILLI_BootSubSection_Kernel EXTENDS ILLI_BootSubSection
  67.         {
  68.                 final public function __construct(ILLI_BootSection_Kernel $ILLI_BootSection_System)
  69.                         {return $this->init();}
  70.         }
  71.        
  72.         FINAL CLASS ILLI_BootSubSection_KernelTest EXTENDS ILLI_BootSubSection_System
  73.         {
  74.                 protected function init()
  75.                 {
  76.                         return $this;
  77.                 }
  78.         }
  79.        
  80.         FINAL CLASS ILLI_BootSubSection_KernelHeader EXTENDS ILLI_BootSubSection_System
  81.         {
  82.                 protected function init()
  83.                 {
  84.                         return $this;
  85.                 }
  86.         }
  87.        
  88.         FINAL CLASS ILLI_BootSubSection_KernelCore EXTENDS ILLI_BootSubSection_System
  89.         {
  90.                 protected function init()
  91.                 {
  92.                         return $this;
  93.                 }
  94.         }
  95.        
  96.         FINAL CLASS ILLI_BootSubSection_KernelParams EXTENDS ILLI_BootSubSection_System
  97.         {
  98.                 protected function init()
  99.                 {
  100.                         return $this;
  101.                 }
  102.         }
  103.        
  104.         FINAL CLASS ILLI_BootSubSection_KernelForwarder EXTENDS ILLI_BootSubSection_System
  105.         {
  106.                 protected function init()
  107.                 {
  108.                         return $this;
  109.                 }
  110.         }
  111.        
  112.         FINAL CLASS ILLI_BootSubSection_KernelDispatcher EXTENDS ILLI_BootSubSection_System
  113.         {
  114.                 protected function init()
  115.                 {
  116.                         return $this;
  117.                 }
  118.         }
  119.        
  120.         FINAL CLASS ILLI_BootSection_Exception EXTENDS ILLI_Exception{}
  121.        
  122.         ABSTRACT CLASS ILLI_BootSection
  123.         {
  124.                 protected function __clone() {}        
  125.                 final public function __construct(ILLI_Bootloader $ILLI_Bootloader)
  126.                         {return $this->init();}
  127.                 abstract protected function init();            
  128.         }
  129.        
  130.         FINAL CLASS ILLI_BootSection_System EXTENDS ILLI_BootSection
  131.         {
  132.                 private static $ERRORS       = NULL;
  133.                 private static $REQUIREMENTS = NULL;
  134.                 private static $REGISTRY     = NULL;
  135.                
  136.                 protected function init()
  137.                 {
  138.                         return $this;
  139.                 }
  140.         }
  141.  
  142.         FINAL CLASS ILLI_BootSection_Settings EXTENDS ILLI_BootSection
  143.         {
  144.                 private static $CORE         = NULL;
  145.                 private static $APPLICATION  = NULL;
  146.                
  147.                 protected function init()
  148.                 {
  149.                         return $this;
  150.                 }
  151.         }
  152.  
  153.         FINAL CLASS ILLI_BootSection_Kernel EXTENDS ILLI_BootSection
  154.         {
  155.                 private static $TEST         = NULL;
  156.                 private static $HEADERS      = NULL;
  157.                 private static $CORE         = NULL;
  158.                 private static $PARAMS       = NULL;
  159.                 private static $FORWARDER    = NULL;
  160.                 private static $DISPATCHER   = NULL;
  161.                
  162.                 protected function init()
  163.                 {
  164.                         return $this;
  165.                 }
  166.         }
  167.        
  168.         FINAL CLASS ILLI_Bootloader_Exception EXTENDS ILLI_Exception{}
  169.        
  170.         FINAL CLASS ILLI_Bootloader
  171.         {
  172.                 private static $SELF = NULL;
  173.                 private static $initialized = FALSE;
  174.                 private static $executed = FALSE;
  175.                 private static $bootsections = array();
  176.        
  177.                 private function __construct(){}
  178.                 private function __clone() {}
  179.                
  180.                 public static function init(ILLI_Constructeur $ILLI_Constructeur)
  181.                 {
  182.                         try
  183.                         {
  184.                                 if(FALSE === self::$initialized)
  185.                                         self::$initialized = TRUE;
  186.                                 else throw new ILLI_Bootloader_Exception('BOOTLOADER already initialized.');
  187.  
  188.                                 if(NULL === self::$SELF)
  189.                                         self::$SELF = new self;
  190.                
  191.                                 self::$SELF
  192.                                         ->boot('System')
  193.                                         ->boot('Settings')
  194.                                         ->boot('Kernel');
  195.                                        
  196.                                 var_dump(self::$bootsections);
  197.                                        
  198.                                 return self::$SELF;
  199.                         }
  200.                         catch(ILLI_Bootloader_Exception $e){$e->w();}
  201.                 }
  202.        
  203.                 public static function run(ILLI_Bootloader $ILLI_Bootloader)
  204.                 {
  205.                         try
  206.                         {
  207.                                 if(FALSE === self::$executed)
  208.                                         self::$executed = TRUE;
  209.                                 else throw new ILLI_Bootloader_Exception('Can not execute BOOTLOADER again.');
  210.                         }
  211.                         catch(ILLI_Bootloader_Exception $e){$e->w();}
  212.                         return self::$SELF;
  213.                 }
  214.                
  215.                 private static function boot($name = '')
  216.                 {
  217.                         try
  218.                         {
  219.                                 if(!is_string($name) || empty($name) || is_null($name))
  220.                                         throw new ILLI_Bootloader_Exception('Illegal instance-name given.');
  221.                                        
  222.                                 $name = 'ILLI_BootSection_'.$name;
  223.                        
  224.                                 if(!class_exists($name, FALSE))
  225.                                         throw new ILLI_Bootloader_Exception('Class not found.');
  226.                         }
  227.                         catch(ILLI_Bootloader_Exception $e){$e->w();}
  228.                        
  229.                         self::$bootsections[$name] = new $name(self::$SELF);
  230.                        
  231.                         return self::$SELF;
  232.                 }
  233.         }
  234.        
  235.         FINAL CLASS ILLI_Constructuer_Exception EXTENDS ILLI_Exception{}
  236.        
  237.         FINAL CLASS ILLI_Constructeur
  238.         {
  239.                 private static $SELF        = NULL;
  240.                 private static $BOOT        = NULL;
  241.                 private static $API         = NULL;
  242.                 private static $CTR         = NULL;
  243.                 private static $OUT         = NULL;
  244.                 private static $initialized = FALSE;
  245.                 private static $executed    = FALSE;
  246.                
  247.                 private function __construct() {}
  248.                 private function __clone() {}
  249.        
  250.                 public static function init(ILLI $ILLI)
  251.                 {
  252.                         try
  253.                         {
  254.                                 if(FALSE === self::$initialized)
  255.                                 {
  256.                                         if(NULL === self::$SELF)
  257.                                                 self::$SELF = new self;
  258.                
  259.                                         self::$initialized = TRUE;
  260.                                
  261.                                         self::$BOOT =& ILLI_Bootloader::init(self::$SELF);
  262.                                                        
  263.                                         return self::$SELF;
  264.                                 }
  265.                                 else throw new ILLI_Constructuer_Exception('ILLI already initialized..');
  266.                         }
  267.                         catch(ILLI_Constructuer_Exception $e){$e->w();}
  268.                 }
  269.        
  270.                 public static function run(ILLI_Constructeur $ILLI_Constructeur)
  271.                 {
  272.                         try
  273.                         {
  274.                                 if(FALSE === self::$initialized)
  275.                                         throw new ILLI_Constructuer_Exception('BOOTLOADER not initialized.');
  276.                                        
  277.                                 if(FALSE === self::$executed)
  278.                                         self::$executed = TRUE;
  279.                                 else throw new ILLI_Constructuer_Exception('Can not execute ILLI again.');
  280.                         }
  281.                         catch(ILLI_Constructuer_Exception $e){$e->w();}
  282.                                
  283.                         return self::$SELF;
  284.                 }
  285.                
  286.                 public static function shutdown(ILLI_Constructeur $ILLI_Constructeur)
  287.                 {
  288.                         /*
  289.                                 shutdown stuff
  290.                         */
  291.                
  292.                         self::$initialized = FALSE;
  293.                         self::$executed    = FALSE;
  294.                         self::$SELF        = NULL;
  295.                         self::$BOOT        = NULL;
  296.                         self::$API         = NULL;
  297.                         self::$CTR         = NULL;
  298.                         self::$OUT         = NULL;
  299.                 }
  300.         }
  301.        
  302.        
  303.         FINAL CLASS ILLI
  304.         {
  305.                 private static $SELF = NULL;
  306.                 private static $CONSTRUCTUER = NULL;
  307.                                
  308.                 private function __construct()
  309.                 {
  310.                         self::$CONSTRUCTUER =& ILLI_Constructeur::init($this);
  311.                 }
  312.                
  313.                 private function __clone(){}
  314.                
  315.                 public static function init()
  316.                 {
  317.                         self::$SELF =& new self;
  318.                         return self::$SELF;
  319.                 }
  320.                
  321.                 public function run()
  322.                 {
  323.                         self::$CONSTRUCTUER
  324.                                 -> run(self::$CONSTRUCTUER);                           
  325.                         return $this;
  326.                 }
  327.                
  328.                 private function shutdown()
  329.                 {
  330.                         self::$CONSTRUCTUER->shutdown(self::$CONSTRUCTUER);
  331.                         self::$CONSTRUCTUER = NULL;
  332.                         self::$SELF = NULL;
  333.                 }
  334.                
  335.         }