public function resolve($class, array $params = array())
	{
		$alias = null;

		if (isset($this->aliases[$class])) {
			$alias = $class;
			$class = $this->aliases[$class];
		}

		// will throw an exception if the class or alias is protected
		$this->checkProtected($class, $alias);

		// if the class is shared, an instance may already exist
		if (isset($this->instances[$class])) {
			return $this->instances[$class];
		}

		if (isset($this->params[$class])) {
			$params = array_replace($this->params[$class], $params);
		}

		// internal classes don't need to be protected when resolving
		// dependencies. save the previous protectInternals value, it will be
		// reset after resolving dependencies
		$previousState = $this->protectInternals;
		$this->protectInternals = false;

		// if no factory is defined for the class, create one
		if (!isset($this->factories[$class]) && $this->autowire) {
			$this->factories[$class] = Definition::getDefaultForClass($class);
		}

		if (!isset($this->factories[$class])) {
			if ($alias) {
				$class = "$class (via $alias)";
			}
			throw new Exception\ResolvingException("No factory defined for $class");
		}

		$object = $this->callFactory($this->factories[$class], $params);

		$this->protectInternals = $previousState;

		if ($object instanceof ContainerAwareInterface) {
			$object->setContainer($this);
		}

		if ($alias) {
			$this->callResolvingCallbacks($alias, $object);
		}
		$this->callResolvingCallbacks($class, $object);

		if ($this->isShared($class)) {
			$this->instances[$class] = $object;
		}

		return $object;
	}
public function resolve($class, array $params = array())
	{
		$alias = null;

		if (isset($this->aliases[$class])) {
			$alias = $class;
			$class = $this->aliases[$class];
		}

		// will throw an exception if the class or alias is protected
		$this->checkProtected($class, $alias);

		// if the class is shared, an instance may already exist
		if (isset($this->instances[$class])) {
			return $this->instances[$class];
		}

		if (isset($this->params[$class])) {
			$params = array_replace($this->params[$class], $params);
		}

		// internal classes don't need to be protected when resolving
		// dependencies. save the previous protectInternals value, it will be
		// reset after resolving dependencies
		$previousState = $this->protectInternals;
		$this->protectInternals = false;

		// if no factory is defined for the class, create one
		if (!isset($this->factories[$class]) && $this->autowire) {
			$this->factories[$class] = Definition::getDefaultForClass($class);
		}

		if (!isset($this->factories[$class])) {
			if ($alias) {
				$class = "$class (via $alias)";
			}
			throw new Exception\ResolvingException("No factory defined for $class");
		}

		$object = $this->callFactory($this->factories[$class], $params);

		$this->protectInternals = $previousState;

		if ($object instanceof ContainerAwareInterface) {
			$object->setContainer($this);
		}

		if ($alias) {
			$this->callResolvingCallbacks($alias, $object);
		}
		$this->callResolvingCallbacks($class, $object);

		if ($this->isShared($class)) {
			$this->instances[$class] = $object;
		}

		return $object;
	}
{@inheritdoc}