@param null $appName

@return ServiceLocator
173964
private static function determineService($appName = null) : ServiceLocator
    {
        if ($appName === null) {
            $service = !isset(self::$serviceCollections)
                ? new ServiceLocator(new App())
                : self::getDefault();
            return $service;
        }

        return self::getService($appName);
    }
247173
final public static function detectAppType(string $appname):string
    {
        $apptype = 'none';
        $appsp = AppTools::registerApps();
        $appbs = AppTools::registerBaseApps();

        foreach ($appsp as $one => $val) {
            if ($one == $appname) {
                return ('simple');
            }
        }

        foreach ($appbs as $one => $val) {
            if ($val['name'] == $appname) {
                return ('base');
            }
        }

        return ($apptype);
    }
71414
public function getOneLocaleActivity(string $appname):Renderer
    {

        $locale = new AppLocale($appname);
        $localeFormat =  ["app" => $appname, "enabled" => $locale->isEnabled(), "values" => $locale->getValues(),
            "prefered" => $locale->getPrefer(), "transtype" => $locale->getTranstype()];

        return ((new Renderer())->jsonRenderer(array("code" => 200, "results" => $localeFormat)));
    }
391821
public function getAppMapper()
    {
        if (null === $this->appMapper) {
            $this->appMapper = $this->getServiceManager()->get('playgroundfacebook_app_mapper');
        }

        return $this->appMapper;
    }
657371
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var ModuleOptionsPluginManagerInterface $moduleOptionsPluginManager */
        $moduleOptionsPluginManager = $appServiceLocator->get(ModuleOptionsPluginManagerInterface::class);

        $resolverByModuleContextMap = new ResolverByClassName($moduleOptionsPluginManager);

        return $resolverByModuleContextMap;
    }
696840
public function createService(ServiceLocatorInterface $serviceLocator)
    {
        $appServiceLocator = $serviceLocator;
        if ($serviceLocator instanceof AbstractPluginManager) {
            $appServiceLocator = $serviceLocator->getServiceLocator();
        }

        /** @var DoctrineObjectManager $doctrineObjectManager */
        $doctrineObjectManager = $appServiceLocator->get(DoctrineObjectManager::class);

        /** @var EntityMapCacheInterface $entityMapCache */
        $entityMapCache = $appServiceLocator->get(EntityMapCacheInterface::class);

        return new EntityMapBuilderController($doctrineObjectManager, $entityMapCache);
    }
792532
protected function getAppConfig($appName, $refresh = true)
    {
        $webApp = $this->api()
            ->getCurrentDeployment($this->getSelectedEnvironment(), $refresh)
            ->getWebApp($appName);

        return AppConfig::fromWebApp($webApp)->getNormalized();
    }
1311010
public function get($serviceName)
    {
        if (! $this->has($serviceName)) {
            throw new NotFoundException('Error: Could not find service');
        }

        $serviceProvider = $this->serviceProviders[$serviceName];

        if (! is_string($serviceProvider)) {
            throw new ContainerException(
                'Error: Expected class name of service provider as string but got "'.gettype($serviceProvider).'"'
            );
        }

        try {
            // The name of the service provider class is stored, try to create an object from it
            /** @var AbstractServiceProvider $serviceProvider */
            $serviceProvider = new $serviceProvider($serviceName, $this);
        } catch (\Exception $exception) {
            throw new ContainerException('Error: Could not create service provider via reflection');
        }

        if (! is_a($serviceProvider, AbstractServiceProvider::class)) {
            throw new ContainerException(
                'Error: Service provider object does not inherit from AbstractServiceProvider'
            );
        }

        try {
            // Try to make the provider provide the service. Might throw an exception.
            $object = $serviceProvider->provide();
        } catch (\Exception $exception) {
            if (is_a($exception, ContainerException::class)) {
                /** @var ContainerException $exception */
                throw $exception;
            } else {
                throw new ContainerException(
                    'Error: Service provider could not create service. Reason: '.$exception->getMessage()
                );
            }
        }

        if (! is_object($object)) {
            throw new ContainerException('Error: Service provider did not provide a valid service object');
        }

        return $object;
    }
1097306
public function getById($appId, array $queryParams = [])
    {
        $response = $this->api->applications()->getById($appId, $queryParams);

        return new ApplicationResponse($response);
    }
1359229
public function createForService($serviceName) {
		if ($this->_basePath === null) {
			throw new ConfigError('Base path was not given');
		}
		
		$filename = $this->_filenameTemplate;
		
		if (strpos($filename, self::PATTERN_SERVICE) !== false) {
			$filename = str_replace(self::PATTERN_SERVICE, $serviceName, $filename);
		}
		
		if (strpos($filename, self::PATTERN_DATE) !== false) {
			$filename = str_replace(self::PATTERN_DATE, date($this->_dateFormat), $filename);
		}
		
		$path = $this->_basePath;
		
		if ($this->_separateDirs) {
			$path .= DIRECTORY_SEPARATOR . $serviceName;
			
			if ((! file_exists($path) || ! is_dir($path)) && ! mkdir($path)) {
				throw new NoDirectory('Directory does not exists and unable to create: "' . $path . '"');
			}
		}
		
		$path .= DIRECTORY_SEPARATOR . $filename;
		
		if (isset($this->_loggers[$serviceName])) {
			return $this->_loggers[$serviceName];
		}
		
		$adapter = $this->getCreateCallback()->__invoke($path);
		$logger  = new Logger($adapter);
		
		$this->_loggers[$serviceName] = $logger;
		return $logger;
	}
1353837
protected static function _find_app($name = null)
	{
		$found = array();

		$files = new \GlobIterator(APPPATH.\Config::get('migrations.folder').'*_*.php');
		foreach($files as $file)
		{
			$found[] = $file->getPathname();
		}

		return $found;
	}
1135264
public function buildApp(string $environmentName) : App
    {
        // create IoC container with middleware instances
        $middleware = new IoCContainerFromConfigArray($this->cfg->get('middleware'));

        // create IoC container with modules
        $modules = new IoCContainerFromConfigArray($this->cfg->get('modules'));

        // build and return app
        $app = new AppDefault($environmentName, $this->cfg, $modules, $middleware);
        return $app;
    }
772430
public function get($name)
    {
        if (!isset($this->services[$name])) {
            throw ServiceNotFoundException::fromName($name);
        }

        return $this->services[$name]($this);
    }
272306
final public static function createAppProcess($appname, $temp)
    {
        $base = __DIR__."/../../";
        include_once $base . "vendor/iumio/framework/Core/Server/Server.php";
        $temdirbase = $base. "vendor/iumio/framework/Core/Additional/Manager/Module/App/AppTemplate";
        $tempdir = ($temp == "0")? $temdirbase.'/notemplate/{appname}' : $temdirbase.'/template/{appname}';
        \iumioFramework\Core\Server\Server::copy(
            $tempdir,
            $base."apps/".$appname,
            'directory'
        );
        $napp = $base."apps/".$appname;

        // APP
        $f = file_get_contents($napp."/{appname}.php.local");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/{appname}.php.local", $str);
        rename($napp."/{appname}.php.local", $napp."/$appname.php");

        // RT
        $f = file_get_contents($napp."/Routing/default.merc");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/Routing/default.merc", $str);

        // MASTER
        $f = file_get_contents($napp."/Masters/DefaultMaster.php.local");
        $str = str_replace("{appname}", $appname, $f);
        file_put_contents($napp."/Masters/DefaultMaster.php.local", $str);
        rename($napp."/Masters/DefaultMaster.php.local", $napp."/Masters/DefaultMaster.php");

        // REGISTER TO APP CORE
        $f = json_decode(file_get_contents($base."/elements/config_files/core/apps.json"));
        $lastapp = 0;

        if (!is_object($f)) {
            $f = new \stdClass();
        }

        foreach ($f as $one => $val) {
            $lastapp++;
        }

        $f->$lastapp = new \stdClass();
        $f->$lastapp->name = $appname;
        $f->$lastapp->enabled = "yes";
        $f->$lastapp->prefix = "";
        $f->$lastapp->class = "\\".$appname."\\".$appname;
        $ndate = new \DateTime('UTC');
        $f->$lastapp->creation = $ndate;
        $f->$lastapp->update = $ndate;
        $f = json_encode($f, JSON_PRETTY_PRINT);
        file_put_contents($base."/elements/config_files/core/apps.json", $f);
        if ($temp == "1") {
            \iumioFramework\Core\Server\Server::copy(
                $base."/apps/".
                $appname."/Front/Resources/",
                $base."/public/components/apps/dev/".strtolower($appname),
                'directory',
                true
            );
        }

        self::initialJSON();
        unset($_SESSION['version']);
        return ("OK");
    }
824750
public static function getViewHelper($appName = null, bool $layout = false)
    {
        if ($appName === false) {
            $class = '\Osf\View\Helper';
            $instance = 'osf';
        } else {
            $appName = $appName === null ? Router::getDefaultControllerName(true) : $appName;
            $class = "\\App\\" . $appName . '\View\Helper';
            $instance = $appName;
        }
        $viewName = $layout ? 'layout' : 'view';
        $instance .= $layout ? '_l' : '_v';
        return self::buildObject($class, [$viewName]); //, $instance);
    }
723160
public static function createService($serviceName)
    {
        switch ($serviceName) {
            case self::SERVICE_REST:
                return new RestService();
            break;
            case self::SERVICE_SOAP:
                return new SoapService();
            break;
            case self::SERVICE_XMLRPC:
                return new XmlRpcService();
            break;
        }

        throw new \Exception(sprintf('Unknown service %s', $serviceName));
    }
1010551
public static function appPath(?string $app = null): ?string
    {
        self::initialize();
        if ($app === null) {
            $app = '*';
        }
        if (isset(self::$repositories[$app])) {
            return call_user_func([self::$repositories[$app], 'getPath']);
        }
        return null;
    }