Undefined
By: Guest | Date: Mar 27 2010 12:39 | Format: PHP | Expires: never | Size: 5.15 KB | Hits: 955
- <?php
- FINAL CLASS ILLI_InstanceLoader
- {
- private $classNamePrefix = '';
- private $classNameSuffix = '';
- private $referenceObject = NULL;
- private $fileLocation = '';
- private $includeLocation = '';
- private function __clone() {}
- public function __construct($fileLocation = '')
- {
- $this->fileLocation = $fileLocation;
- // yayaaa it suxx
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_InstanceConstructeur.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsPrimary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsSecondary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsTertiary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsQuarternary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsQuinary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsSenary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsSeptary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsOctanary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsNonary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Sequence_ShortcutsDenary.Abstract.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Exception.php';
- require_once ILLI_INSTALL_DIR.'ILLI_Sequence'.DIRECTORY_SEPARATOR.'Abstract.php';
- }
- public function __get($name)
- {
- try
- {
- throw new ILLI_InstanceLoader_Exception
- ('Illegal instance-name given.');
- $name = $this->classNamePrefix.$name.$this->classNameSuffix;
- throw new ILLI_InstanceLoader_Exception
- ('Instance '.$name.' not found.');
- }
- catch(ILLI_InstanceLoader_Exception $e){$e->w();}
- return $this->instanceQueue[$name];
- }
- public function setNameMask($prefix = '', $suffix = '')
- {
- try
- {
- throw new ILLI_InstanceLoader_Exception
- ('Illegal prefix of instance-name given.');
- throw new ILLI_InstanceLoader_Exception
- ('Illegal suffix of instance-name given.');
- $this->classNamePrefix = $prefix;
- $this->classNameSuffix = $suffix;
- }
- catch(ILLI_InstanceLoader_Exception $e){$e->w();}
- return $this;
- }
- public function setReferenceObject(&$OBJ)
- {
- try
- {
- throw new ILLI_InstanceLoader_Exception
- ('Illegal reference-object given.');
- $this->referenceObject =& $OBJ;
- }
- catch(ILLI_InstanceLoader_Exception $e){$e->w();}
- return $this;
- }
- public function getReferenceObject()
- {
- return $this->referenceObject;
- }
- private function loadClassFile($type, $required = FALSE)
- {
- $path = $this->includeLocation.$type.'.php';
- try
- {
- if($required)
- throw new ILLI_InstanceLoader_Exception
- ('Class-File '.$path.' not found.');
- }
- catch(ILLI_InstanceLoader_Exception $e){$e->w();}
- $loaded = require_once $path;
- return $this;
- }
- public function load($name = '')
- {
- try
- {
- throw new ILLI_InstanceLoader_Exception
- ('Illegal instance-name given.');
- $this->fileLocation = ILLI_INSTALL_DIR.$this->classNamePrefix.DIRECTORY_SEPARATOR;
- $this->includeLocation = $this->fileLocation.$name.DIRECTORY_SEPARATOR;
- $this
- ->loadClassFile('Exception')
- ->loadClassFile('Abstract')
- ->loadClassFile('Class', TRUE)
- ->loadClassFile('Package');
- $className = $this->classNamePrefix.$name.$this->classNameSuffix;
- throw new ILLI_InstanceLoader_Exception
- ('Class '.$className.' not found.');
- throw new ILLI_InstanceLoader_Exception
- ('Instance of '.$className.' exists.');
- ? $this->instanceQueue[$className] =& new $className($this->referenceObject, $this->includeLocation)
- : $this->instanceQueue[$className] =& new $className();
- }
- catch(ILLI_InstanceLoader_Exception $e){$e->w();}
- return $this;
- }
- public function init()
- {
- foreach($this->instanceQueue as $instance)
- $instance->init();
- return $this;
- }
- public function run()
- {
- foreach($this->instanceQueue as $instance)
- $instance->execute();
- return $this;
- }
- }
Latest pastes
2 hours ago
1 days ago
1 days ago
2 days ago
2 days ago