Example #1
0
 public function determineContext($class, $grath = null)
 {
     if ($grath == 'default') {
         return $this->top;
     } else {
         return $this->top->determineContext($class, 'default');
     }
 }
Example #2
0
 public function instantiate(Context $context, $nesting, $graph = null)
 {
     $graph = $this->graph ?: ($graph ?: 'default');
     if (!isset($this->instance[$graph])) {
         $this->instance[$graph] = parent::instantiate($context->determineContext($this->class, $graph), $nesting, $graph);
     }
     return $this->instance[$graph];
 }
Example #3
0
 public function determineContext($class, $graph = null)
 {
     $graph = $graph ?: 'default';
     if (isset($this->contexts[$graph])) {
         foreach ($this->contexts[$graph] as $type => $context) {
             if ($this->repository()->isSupertype($class, $type)) {
                 return $context;
             }
         }
     }
     return $this->parent->determineContext($class, $graph);
 }
Example #4
0
 public function instantiate(Context $context, $nesting, $graph = null)
 {
     $instances = [];
     foreach ($this->preferences as $preference) {
         if ($preference instanceof Lifecycle) {
             $preferContext = empty($preference->class) ? $context : $context->determineContext($preference->class, $graph);
             $instances[] = $preference->instantiate($preferContext, $nesting, $graph);
         } elseif (!is_string($preference)) {
             $instances[] = $preference;
         } else {
             $instances[] = $context->create($preference, $nesting, $graph);
         }
     }
     return $instances;
 }
Example #5
0
 public function instantiate(Context $context, $nesting, $graph = null)
 {
     return parent::instantiate($context->determineContext($this->class, $this->graph), $nesting, $this->graph);
 }