Contao\System::import PHP Méthode

import() protected méthode

Import a library and make it accessible by its name or an optional key
protected import ( string $strClass, string $strKey = null, boolean $blnForce = false )
$strClass string The class name
$strKey string An optional key to store the object under
$blnForce boolean If true, existing objects will be overridden
    protected function import($strClass, $strKey = null, $blnForce = false)
    {
        $strKey = $strKey ?: $strClass;
        if ($blnForce || !isset($this->arrObjects[$strKey])) {
            $container = static::getContainer();
            if (!class_exists($strClass) && $container->has($strClass)) {
                $this->arrObjects[$strKey] = $container->get($strClass);
            } elseif (in_array('getInstance', get_class_methods($strClass))) {
                $this->arrObjects[$strKey] = call_user_func(array($strClass, 'getInstance'));
            } else {
                $this->arrObjects[$strKey] = new $strClass();
            }
        }
    }