returns the created instance

@param   \stubbles\ioc\Injector  $injector
@param   string                  $name
@return  mixed
@throws  \stubbles\ioc\binding\BindingException
977606
public function getInstance(Injector $injector, $name = null)
    {
        if (null !== $this->instance) {
            return $this->instance;
        }

        if (is_string($this->impl)) {
            $this->impl = new \ReflectionClass($this->impl);
        }

        if (null === $this->scope) {
            if (annotationsOf($this->impl)->contain('Singleton')) {
                $this->scope = $this->scopes->singleton();
            }
        }

        if (null === $this->provider) {
            if (null != $this->providerClass) {
                $provider = $injector->getInstance($this->providerClass);
                if (!($provider instanceof InjectionProvider)) {
                    throw new BindingException('Configured provider class ' . $this->providerClass . ' for type ' . $this->type . ' is not an instance of stubbles\ioc\InjectionProvider.');
                }

                $this->provider = $provider;
            } else {
                $this->provider = new DefaultInjectionProvider($injector, $this->impl);
            }
        }

        if (null !== $this->scope) {
            return $this->scope->getInstance($this->impl, $this->provider);
        }

        return $this->provider->get($name);
    }
1028009
public function getDataMapper($name = null)
    {
        $mapperName = $name ?: $this->dataMapper;

        if ($mapperName === false) {
            return new NullDataMapper();
        }

        $mapperName = $mapperName ?: $this->getName();

        // (1) If name is class, just new it.
        if (class_exists($mapperName)) {
            return new $mapperName($this->table, $this->keys, $this->db);
        }

        // (2): Find object from registered namespaces
        if ($mapper = DataMapperResolver::create($mapperName, $this->table, $this->keys, $this->db)) {
            return $mapper;
        }

        $errors[] = sprintf(
            'DataMapper: "%s" not found from namespaces: (%s)',
            $mapperName,
            implode(" |\n ", DataMapperResolver::dumpNamespaces())
        );

        // (3): Find from package directory.
        $class = sprintf(
            '%s\DataMapper\%sMapper',
            MvcHelper::getPackageNamespace(get_called_class(), 2),
            ucfirst($mapperName)
        );

        if (class_exists($class)) {
            return new $class($this->table, $this->keys, $this->db);
        }

        $errors[] = sprintf('Class: %s not exists.', $class);

        // If name is NULL and this model prepared a default mapper name.
        // We must throw exception to tell developers mapper not found.
        if (!$name && $this->dataMapper) {
            throw new \LogicException(implode("\n- ", $errors));
        }

        // If name not NULL, set it as table name, otherwise use pre-set table property.
        $table = $name ?: $this->table;

        if (!$table) {
            throw new \LogicException(sprintf(
                "Please add table property to %s to support DataMapper object. \n%s",
                static::class,
                implode("\n- ", $errors)
            ));
        }

        // (4): If name is null, we get default object with table name provided.
        return new DataMapper($table, $this->keys, $this->db);
    }
685139
public function getOrCreateSubject($name)
    {
        if (isset($this->subjects[$name])) {
            return $this->subjects[$name];
        }

        $this->subjects[$name] = new SubjectMetadata($this, $name);

        return $this->subjects[$name];
    }
128870
public static function logger($name = 'Webiny')
    {
        try {
            return ServiceManager::getInstance()->getService('Logger.' . $name);
        } catch (ServiceManagerException $e) {
            if ($e->getCode() == ServiceManagerException::SERVICE_DEFINITION_NOT_FOUND) {
                return new Logger($name, new NullDriver());
            }

            throw $e;
        }

    }
257518
public function singleton($name, $object)
    {
        if (IOC::hasSingleton($name)) {
            return IOC::singleton($name);
        } else {
            IOC::singleton($name, $object);
            return $object;
        }
    }
952415
public function create($name, Closure $resolver)
    {
        $builder = new MenuBuilder($name, $this->config);

        $builder->setViewFactory($this->views);

        $this->menus[$name] = $builder;

        return $resolver($builder);
    }
1202871
public function factory(Injector $injector)
	{
		$this->injector  = $injector;
		$this->constructed = true;

		return $this;
	}
1175297
public static function getInstance($name=null) {
		if( !$name ) {
			$name = 'default';
		}
		if( !isset(static::$instances[$name]) ) {
			static::make($name);
		}
		return static::$instances[$name];
	}
543885
private function getInjector(\ReflectionClass $reflection): InjectorInterface
    {
        if (isset($this->injectors[$reflection->getName()])) {
            //Stated directly
            $injector = $this->get($this->injectors[$reflection->getName()]);
        } else {
            //Auto-injection!
            $injector = $this->get($reflection->getConstant('INJECTOR'));
        }

        if (!$injector instanceof InjectorInterface) {
            throw new InjectionException(sprintf(
                "Class '%s' must be an instance of InjectorInterface for '%s'",
                get_class($injector),
                $reflection->getName()
            ));
        }

        return $injector;
    }
1020225
public function fetchObject($name='stdClass', $ctor_args=null)
    {
        try {
            $data = $this->fetch(\PDO::FETCH_ASSOC);
            return $this->_createObjectFromData($name, $data);
        } catch (\Exception $e) {
            return null;
        }
    }
98449
protected function getInputFilterByName(ServiceLocatorInterface $serviceLocator, $name)
    {
        if ($serviceLocator->has('InputFilterManager')) {
            $serviceLocator = $serviceLocator->get('InputFilterManager');
        }

        $obj = $serviceLocator->get($name);
        if (!$obj instanceof InputFilterInterface) {
            throw new Exception\RuntimeException(sprintf(
                'Instance of type %s is invalid; must implement %s',
                (is_object($obj) ? get_class($obj) : gettype($obj)),
                InputFilterInterface::class
            ));
        }
        return $obj;
    }
875587
public static function create(string $name, string $bindTo = ''): Base
    {
        $fullName = __NAMESPACE__ . '\\Widget\\' . $name;
        $widget = class_exists($fullName) ? new $fullName() : new Widget\Base('kendo' . $name);

        if ($bindTo) {
            $widget->bindTo($bindTo);
        }

        return $widget;
    }
393745
public function getInstance(string $type, $name = null)
    {
        if (__CLASS__ === $type) {
            return $this;
        }

        array_push($this->injectionStack, $type . '#' . $name);
        $instance = $this->getBinding($type, $name)->getInstance($this, $name);
        array_pop($this->injectionStack);
        return $instance;
    }
470289
public function getInjectablePropertyBySetter($name) {
    	$properties = $this->getInjectablePropertiesBySetter();
    	return isset($properties[$name])?$properties[$name]:null;
    }
407077
private function processCreateDI($name)
    {
        $this->dependencyService->processCommand('injectModel', $name);
        $this->dependencyService->create($name);
    }
621113
public function injectAdapter(AdapterInterface $adapter, ?string $name = null): self
    {
        if (null === $name) {
            $name = get_class($adapter);
        }

        $this->logger->debug('inject auth adapter ['.$name.'] of type ['.get_class($adapter).']', [
            'category' => get_class($this),
        ]);

        if ($this->hasAdapter($name)) {
            throw new Exception\AdapterNotUnique('auth adapter '.$name.' is already registered');
        }

        $this->adapter[$name] = $adapter;

        return $this;
    }
366951
public function createElement($name)
    {
        $elementClass = $this->classNameResolver->resolveElement($name);

        return $this->instantiateElement($elementClass);
    }