/** * Resolve a particular definition from the provider. * * @param string $definitionKey * * @return mixed */ public function resolve($definitionKey) { $container = new Container([]); $resolver = new DefinitionResolver($container); /* @var DefinitionInterface $definition */ $definitions = $this->getDefinitions(); $definition = $definitions[$definitionKey]; return $resolver->resolve($definition); }
public function get($id) { if (array_key_exists($id, $this->entries)) { return $this->entries[$id]; } if (!isset($this->definitions[$id])) { throw EntryNotFound::fromId($id); } $this->entries[$id] = $this->resolver->resolve($this->definitions[$id]); return $this->entries[$id]; }
/** * @param string $identifier * @param DefinitionInterface $definition * * @throws InvalidDefinition * @throws UnsupportedDefinition * * @return mixed */ private function resolve($identifier, DefinitionInterface $definition) { $resolver = new DefinitionResolver($this); $service = $resolver->resolve($definition); // Add extensions if (array_key_exists($identifier, $this->extensions)) { foreach ($this->extensions[$identifier] as $extension) { $service = $this->callAssignments($service, $extension); $service = $this->callMethods($service, $extension); } } return $service; }