core-bundle/src/Resources/contao/library/Contao/System.php
protected function import($strClass, $strKey=null, $blnForce=false)
	{
		$strKey = $strKey ?: $strClass;

		if (\is_object($strKey))
		{
			$strKey = \get_class($strClass);
		}

		if ($blnForce || !isset($this->arrObjects[$strKey]))
		{
			$container = static::getContainer();

			if (\is_object($strClass))
			{
				$this->arrObjects[$strKey] = $strClass;
			}
			elseif ($container->has($strClass) && (strpos($strClass, '\\') !== false || !class_exists($strClass)))
			{
				$this->arrObjects[$strKey] = $container->get($strClass);
			}
			elseif ($container instanceof Container && isset($container->getRemovedIds()[$strClass]))
			{
				throw new ServiceNotFoundException($strClass, null, null, array(), sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $strClass));
			}
			elseif (\in_array('getInstance', get_class_methods($strClass)))
			{
				$this->arrObjects[$strKey] = \call_user_func(array($strClass, 'getInstance'));
			}
			else
			{
				$this->arrObjects[$strKey] = new $strClass();
			}
		}
	}
protected function import($strClass, $strKey=null, $blnForce=false)
	{
		$strKey = $strKey ?: $strClass;

		if (\is_object($strKey))
		{
			$strKey = \get_class($strClass);
		}

		if ($blnForce || !isset($this->arrObjects[$strKey]))
		{
			$container = static::getContainer();

			if (\is_object($strClass))
			{
				$this->arrObjects[$strKey] = $strClass;
			}
			elseif ($container->has($strClass) && (strpos($strClass, '\\') !== false || !class_exists($strClass)))
			{
				$this->arrObjects[$strKey] = $container->get($strClass);
			}
			elseif ($container instanceof Container && isset($container->getRemovedIds()[$strClass]))
			{
				throw new ServiceNotFoundException($strClass, null, null, array(), sprintf('The "%s" service or alias has been removed or inlined when the container was compiled. You should either make it public, or stop using the container directly and use dependency injection instead.', $strClass));
			}
			elseif (\in_array('getInstance', get_class_methods($strClass)))
			{
				$this->arrObjects[$strKey] = \call_user_func(array($strClass, 'getInstance'));
			}
			else
			{
				$this->arrObjects[$strKey] = new $strClass();
			}
		}
	}
Import a library and make it accessible by its name or an optional key

@param string  $strClass The class name
@param string  $strKey   An optional key to store the object under
@param boolean $blnForce If true, existing objects will be overridden

@throws ServiceNotFoundException