Example #1
0
 /**
  * construct an all depended classes
  *
  * @return object
  */
 protected function buildInstance()
 {
     $stackCount = (int) count($this->dependency);
     if ($stackCount < 1) {
         $msg = "invalid stack count";
         throw new Sabel_Exception_Runtime($msg);
     }
     $instance = null;
     for ($i = 0; $i < $stackCount; ++$i) {
         $reflection = array_pop($this->dependency);
         if ($reflection === null) {
             continue;
         }
         $className = $reflection->getName();
         if ($this->config->hasConstruct($className)) {
             $instance = $this->newInstance($className);
         } else {
             if ($reflection->isInstanciatable()) {
                 $instance = $this->getInstance($className, $instance);
             } else {
                 $instance = $this->newInstance($className);
             }
         }
     }
     return $instance;
 }
Example #2
0
 public function add(Sabel_Container_Injection $config)
 {
     $config->configure();
     $this->configs[] = $config;
 }