Инстанцирование приложения.

@param string $appClass
@return ApplicationInterface
542701
public function instanceApp(string $appClass): ApplicationInterface
    {
        return $this
            ->container
            ->getApplicationContainer()
            ->add($this->applicationLoader->instanceApp($appClass));
    }
1345558
public function addExtension(ExtensionInterface $extension): App
    {
        try {
            if (!$extension->isInitialized()) {
                $extension->init($this);
            }
        } catch (\Exception $e) {
            throw new RuntimeException(sprintf('Unable to load extension "%s"', get_class($extension)));
        }

        return $this;
    }
117472
private function getInstance($class, array $args)
    {
        // Hack to avoid Reflection for most cases
        switch (count($args)) {
            case 0:
                return new $class;
            case 1:
                return new $class($args[0]);
            case 2:
                return new $class($args[0], $args[1]);
            case 3:
                return new $class($args[0], $args[1], $args[2]);
            case 4:
                return new $class($args[0], $args[1], $args[2], $args[3]);
            case 5:
                return new $class($args[0], $args[1], $args[2], $args[3], $args[4]);
            case 6:
                return new $class($args[0], $args[1], $args[2], $args[3], $args[4], $args[5]);
            default:
                $reflection = new ReflectionClass();
                return $reflection->newInstanceArgs($args);
        }
    }
1301161
public function setPaths() : ApplicationInterface
    {
        $this->container->set('app', $this);
        $paths = $this->bootstrappers->getBootstrapper()->getPaths();

        foreach ($paths->all() as $key => $path) {
            $this->container->set($key, $path);
        }

        return $this;
    }
952107
protected function loadIntermediateContainerInstance($containerClass): ContainerInterface {
        $arguments = $this->getConfiguration() [AbstractFileConfiguration::SERVICE_INIT_ARGUMENTS] ?? NULL;
        $cfg = $this->getConfiguration() [AbstractFileConfiguration::SERVICE_INIT_CONFIGURATION] ?? NULL;

        try {
            /** @var ContainerInterface $instance */
            $instance = $this->serviceManager->makeServiceInstance($containerClass, $arguments, $cfg);
            if($instance instanceof ContainerInterface)
                return $instance;
            throw new ServiceException("Class $containerClass does not implement ". ContainerInterface::class, 893);
        } catch (\Throwable $e) {
            $e = new BadContainerException($e->getMessage(), $e->getCode(), $e);
            $e->setServiceName($this->serviceName);
            $e->setContainer(NULL);
            throw $e;
        }
    }
742277
public static function autoload($class)
    {
        $baseRoot = Container::get('config')->get('app_full_path');
        // project-specific namespace prefix
        $prefix = Container::get('config')->get('namespace_prefix');

        // does the class use the namespace prefix?
        $len = strlen($prefix);
        if (strncmp($prefix, $class, $len) !== 0) {
            // no, move to the next registered autoloader
            return;
        }

        // get the relative class name
        $relativeClass = substr($class, $len);

        // replace the namespace prefix with the base directory, replace namespace
        // separators with directory separators in the relative class name, append
        // with .php
        $file = $baseRoot . '/' . str_replace('\\', '/', $relativeClass) . '.php';

        self::import($file);
    }
236406
public function entity(string $entityClass) : EntityMapperDefiner
    {
        return new EntityMapperDefiner($this->iocContainer, function (callable $entityMapperFactory) use ($entityClass) {
            $this->entityMapperFactories[] = $entityMapperFactory;
        });
    }
1286819
protected function resolve($class)
    {
        if (class_exists($class) === false) {
            $message = 'Job ' . $class . ' is not found.';

            $this->log('error', $message);

            throw new JobNotFoundException($message);
        } elseif (is_subclass_of($class, 'Indigo\\Queue\\Job\\JobInterface') === false) {
            throw new InvalidJobException($class . 'is not a subclass of Indigo\\Queue\\Job\\JobInterface');
        }

        $job = new $class;

        if (isset($job->config)) {
            $this->config = array_merge($this->config, $job->config);
        }

        return $job;
    }
978771
protected function getPayloadInstance(): AppInterface {
        if (!($this->instance instanceof AppInterface)) {
            $appName = $this->get('appname', null);
            $appNamespace = $this->get('appnamespace', null);

            // Run App
            $appClassName = ucfirst($appName);
            if (!is_null($appNamespace)) {
                $appClassName = "\\{$appNamespace}\\{$appClassName}";
            }

            $this->instance = $this->di->get($appClassName);
        }
        return $this->instance;
    }
779864
private function generateInterface($class)
    {
        $consts = $this->getClassConsts($class);
        $methods = $this->getClassMethods($class);

        $result = '<?php' . PHP_EOL;

        $className = $class->getShortName();
        $namespace = $class->getNamespaceName();
        if('' !== $namespace)
        {
            $namespace = 'namespace ' . $namespace . ';';
        }
        $result .= <<<CODE
{$namespace}

interface {$className}
{
{$consts}{$methods}
}

CODE;
        $path = $this->savePath . '/interfaces/' . str_replace('\\', '/', $class->getNamespaceName()) . '/';
        if(!is_dir($path))
        {
            mkdir($path, 0777, true);
        }
        file_put_contents($path . $class->getShortName() . '.php', $result);
    }
265269
private function getManagerFor($class)
    {
        $manager = $this->doctrine->getManagerForClass($class);

        if ($manager === null) {
            throw new \RuntimeException(
                sprintf(
                    'Class "%s" seems not to be a managed Doctrine entity. Did you forget to map it?',
                    $class
                )
            );
        }

        return $manager;
    }
1335516
protected function instantiator(string $class): InstantiatorInterface
    {
        if (isset($this->instantiators[$class])) {
            return $this->instantiators[$class];
        }

        //Potential optimization
        $instantiator = $this->getFactory()->make(
            $this->define($class, self::D_INSTANTIATOR),
            [
                'class'  => $class,
                'odm'    => $this,
                'schema' => $this->define($class, self::D_SCHEMA)
            ]
        );

        //Constructing instantiator and storing it in cache
        return $this->instantiators[$class] = $instantiator;
    }
571168
private function newInstance($class)
    {
        $entity = $class->newInstance();

        if ($entity instanceof \Doctrine\Common\Persistence\ObjectManagerAware) {
            $entity->injectObjectManager($this->em, $class);
        }

        return $entity;
    }
568405
public function newApp(string $app_type, ApplicationFactoryInterface $app_factory) : ApplicationInterface
    {
        return $app_factory->createApplication($app_type, $this->fs);
    }
709887
public static function beansOfType(ApplicationInterface $applicationContext, $class)
    {
        /**
         * @var $objectManager ObjectManagerInterface
         */
        $objectManager = $applicationContext->search("ObjectManagerInterface");
        $initialContext = new InitialContext();
        $initialContext->injectApplication($applicationContext);
        $beans = array();
        foreach ($objectManager->getObjectDescriptors() as $descriptor) {
            if ($descriptor instanceof ComponentDescriptorInterface) {
                if (is_subclass_of($descriptor->getClassName(), $class)) {
                    $beans[$descriptor->getName()] = $initialContext->lookup($descriptor->getName());
                }
            }
        }
        return $beans;
    }
1085469
protected function resolveClass(?ContainerInterface $container = null, string $class)
    {
        if ($container instanceof ContainerInterface && $container->has($class)) {
            return $container->get($class);
        }

        return new $class();
    }
11661
private function make(string $class)
    {
        if (! array_key_exists($class, $this->instances)) {

            try {

                return $this->instances[$class] = ($this->factory)($class)->value($this);

            }

            catch (ResolvingExceptionInterface $e) {

                throw new ReflectionContainerException($class, $e);

            }

        }

        return $this->instances[$class];
    }