public function getValue() { switch ($this->type) { case self::VALUETYPE_REF: $value = IoCFactory::getInstance($this->value); return $value; case self::VALUETYPE_VALUE: return $this->value; case self::VALUETYPE_EVAL: $value = null; eval("\$value = {$this->value};"); return $value; } }
public function getInstance($constructorArgs) { $factory = parent::getInstance(array()); if (!$factory instanceof IoCClassFactorable) { throw new Exception('Factory do not implements IoCClassFactorable'); } $instance = IoCFactory::getInstance($this->subject); if (count($constructorArgs)) { $args = $this->constructArgs->getArgsArray(); array_unshift($args, $instance); call_user_func_array(array($newClass, $method), $args); } else { $factory->produce($instance); } return $instance; }
* objects. */ $_SESSION['current_user'] = array('user_firstname' => 'john', 'user_id' => 1); $_SERVER['some'] = 'Enviroment value of some'; // Using the Factory /* $injectedAIns = IoCFactory::getInstance('injectionA'); $injectedCIns = IoCFactory::getInstance('injectionC'); $pseudoInjectedAIns = IoCFactory::getInstance('pseudoInjectionA'); $injectedBIns = IoCFactory::getInstance('injectionB'); $injectedDIns = IoCFactory::getInstance('injectionD'); $injectedS1Ins = IoCFactory::getInstance('injASingletonated'); $injectedS2Ins = IoCFactory::getInstance('injASingletonated'); $injectedS3Ins = IoCFactory::getInstance('injectionSingle'); */ $injectedB = IoCFactory::getInstance('factoryA'); //print_r($injected); //print_r($injectedAIns); //print_r($pseudoInjectedAIns); //print_r($injectedBIns); //print_r($injectedCIns); //print_r($injectedDIns); //print_r($injectedS1Ins); //print_r($injectedS2Ins); //print_r($injectedS3Ins); print_r($injectedB); /* * The folowing classes are the ones used to test... **/ class printSelf {