/** * Resolves this binding and returns the instance * * @param inject.Injector $injector * @param var */ public function resolve($injector) { return $injector->newInstance($this->class); }
/** * Configures bindings on given injector * * @param inject.Injector $injector */ public function configure($injector) { $cl = ClassLoader::getDefault(); foreach (array_unique([null, $this->section]) as $section) { $namespaces = []; foreach ($this->properties->readSection($section) as $type => $implementation) { if ('use' === $type) { $namespaces = $implementation; continue; } if (isset(self::$PRIMITIVES[$type])) { foreach ($implementation as $name => $value) { $injector->bind($type, $this->valueIn($value), $name); } } else { $resolved = $this->resolveType($cl, $namespaces, $type); if (is_array($implementation)) { foreach ($implementation as $name => $impl) { $injector->bind($resolved, $this->bindingTo($cl, $namespaces, $impl), $name); } } else { $injector->bind($resolved, $this->bindingTo($cl, $namespaces, $implementation)); } } } } }