Switch app to default
@param string $appname App name
@return Renderer
@throws Server500
516295
public function switchDefaultActivity(string $appname):Renderer
    {
        $file = JL::open(FEnv::get("framework.config.core.apps.file"));
        foreach ($file as $one => $val) {
            if ($val->isdefault == "yes") {
                $val->isdefault = "no";
                $val->update = new \DateTime('UTC');
            }
            if ($val->name == $appname) {
                $val->update = new \DateTime();
                $val->isdefault = "yes";
            }
        }

        $file = json_encode($file, JSON_PRETTY_PRINT);
        JL::put(FEnv::get("framework.config.core.apps.file"), $file);
        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
381766
public function clearActivity(string $appname, string $env):Renderer
    {
        $this->clear($appname, $env);
        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
1265527
public function removeActivity(string $servicename):Renderer
    {
        $removeservice = false;
        $file = JL::open(FEnv::get("framework.config.core.services.file"));
        foreach ($file as $one => $value) {
            if ($one == $servicename) {
                unset($file->$one);
                $removeservice  = true;
                break;
            }
        }

        if ($removeservice == false) {
            return ((new Renderer())->jsonRenderer(array("code" => 500, "msg" => "Service does not exist")));
        }

        $render = json_encode($file, JSON_PRETTY_PRINT);
        file_put_contents(FEnv::get("framework.config.core.services.file"), $render);

        return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
    }
57381
public function setDefaultRenderer($name)
    {
        if (!\array_key_exists($name, $this->renderers)) {
            throw new \InvalidArgumentException(sprintf('Cannot set default exception renderer "%s". It does not exist.', $name));
        }

        $this->defaultRenderer = $name;
    }
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);
    }
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)));
    }
157295
public function publish(string $appname, string $env)
    {
        $this->clear($appname, $env);
        if ($appname == "_all") {
            $dirs = scandir(FEnv::get("framework.apps"));
            foreach ($dirs as $dir) {
                if ($dir == ".") {
                    continue;
                }
                if ($dir == "..") {
                    continue;
                }
                if (!is_dir(FEnv::get("framework.root") . "apps/" . $dir)) {
                    continue;
                }
                if (in_array(strtolower($env), array("dev", "prod", "all"))) {
                    if (file_exists(FEnv::get("framework.root") . "apps/" . $dir . "/Front/Resources/")) {
                        if (strtolower($env) === "dev") {
                            Server::copy(
                                FEnv::get("framework.apps") . $dir . "/Front/Resources/",
                                FEnv::get("framework.root") . "public/components/apps/dev/" . strtolower($dir),
                                'directory',
                                true
                            );
                        } elseif (strtolower($env) == "prod") {
                            Server::copy(
                                FEnv::get("framework.apps"). $dir . "/Front/Resources/",
                                FEnv::get("framework.root") .
                                "public/components/apps/prod/" . strtolower($dir),
                                'directory',
                                false
                            );
                        } else {
                            if (Server::exist(FEnv::get("framework.root") .
                                "apps/" . $dir . "/Front/Resources/")) {
                                Server::copy(FEnv::get("framework.root") .
                                    "apps/" . $dir . "/Front/Resources/", FEnv::get("framework.root") .
                                    "public/components/apps/dev/" . strtolower($dir), 'directory', true);
                                Server::copy(FEnv::get("framework.root") .
                                    "apps/" . $dir . "/Front/Resources/", FEnv::get("framework.root") .
                                    "public/components/apps/prod/" . strtolower($dir), 'directory', false);
                            }
                        }
                    }
                }
            }
        } elseif ($appname !== "") {
            if (in_array(strtolower($env), array("dev", "prod", "all"))) {
                if (file_exists(FEnv::get("framework.root")."apps/" . ($appname) . "/Front/Resources/")) {
                    if (strtolower($env) === "dev") {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/dev/" . strtolower($appname), 'directory', true);
                    } elseif (strtolower($env) == "prod") {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/prod/" . strtolower($appname), 'directory', false);
                    } else {
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/dev/" . strtolower($appname), 'directory', true);
                        Server::copy(FEnv::get("framework.root") .
                            "apps/" . ($appname) . "/Front/Resources/", FEnv::get("framework.root") .
                            "public/components/apps/prod/" . strtolower($appname), 'directory', false);
                    }
                }
            }
        }
    }
1363165
public function clear(string $appname, string $env):int
    {
        if ($appname == "_all" && in_array(strtolower($env), array("dev", "prod", "all"))) {
            if (in_array(strtolower($env), array("dev", "prod"))) {
                Server::delete(FEnv::get("framework.web.components.apps").
                    strtolower($env), 'directory');
                Server::create(FEnv::get("framework.web.components.apps").
                    strtolower($env), 'directory');
            } else {
                Server::delete(FEnv::get("framework.web.components.apps").("dev"), 'directory');
                Server::create(FEnv::get("framework.web.components.apps").("dev"), 'directory');

                Server::delete(FEnv::get("framework.web.components.apps").("prod"), 'directory');
                Server::create(FEnv::get("framework.web.components.apps").("prod"), 'directory');
            }
        }
        if ($appname != "" && in_array(strtolower($env), array("dev", "prod", "all"))) {
            if (in_array(strtolower($env), array("dev", "prod"))) {
                Server::delete(FEnv::get("framework.web.components.apps").
                    strtolower($env)."/".strtolower($appname), 'directory');
            } else {
                Server::delete(FEnv::get("framework.web.components.apps").
                    ("dev")."/".strtolower($appname), 'directory');
                Server::delete(
                    FEnv::get("framework.web.components.apps").
                    ("prod")."/".strtolower($appname),
                    'directory'
                );
            }
        }
        return (1);
    }
217114
final protected function checkAppRegister(string $appname):bool
    {
        $file = json_decode(file_get_contents(FEnvFcm::get("framework.config.core.apps.file")));
        if (empty($file)) {
            return (false);
        }
        foreach ($file as $val) {
            if ($val->name == $appname) {
                return (true);
            }
        }
        return (false);
    }
703675
public function getLocalesFrom():AppLocaleInterface
    {
        $appname = $this->app;
        if (true === JsonListener::exists(FEnv::get("app.config.file"))) {
            if (false === self::isEnabled()) {
                throw new Server500(new \ArrayObject(
                    array("explain" => "Cannot get locale from $appname : Global locale mode is not enabled.",
                        "solution" => "Please enable the locale mode in framework.config.json to use it from your apps")
                ));
            }
            $file = JsonListener::open(FEnv::get("app.config.file"));
            if (true === property_exists($file, "locale_enabled") &&
                true === $file->locale_enabled &&
                true === property_exists($file, "trans_type") &&
                true === property_exists($file, "locale_values") &&
                true === property_exists($file, "prefer_locale")) {
                $vals = $file->locale_values;
                $enabled = $file->locale_enabled;
                $transtype = $file->trans_type;
                $preferlocale = $file->prefer_locale;
                $applocale = new AppLocale();
                $applocale->setEnabled($enabled);
                $applocale->setTranstype($transtype);
                $applocale->setValues((array) $vals);
                $applocale->setAppname($appname);
                $applocale->setPrefer($preferlocale);
                $this->applocale = $applocale;
                return ($applocale);
            }
            throw new Server500(new \ArrayObject(
                array("explain" => "Cannot get locale from $appname : App locale mode is not enabled.",
                "solution" => "Please enable the locale mode in config.json to use it from $appname")
            ));
        }
        throw new Server500(new \ArrayObject(
            array("explain" => "Cannot get locale from $appname : App locale mode is not enabled.",
            "solution" => "Please enable the locale mode in config.json to use it from $appname")
        ));
    }
434457
public function changeStatusLocalAppActivity(string $appname, string $status)
    {
        if ("enabled" === $status) {
            $locale = new AppLocale($appname);
            $locale->setEnabled(true);
            $locale->apply();
            unset($locale);
            $locale = new AppLocale($appname);
            if ($locale->isEnabled()) {
                return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
            } else {
                return ((new Renderer())->jsonRenderer(array("code" => 500,
                    "results" => "Cannot enabled app locale for $appname")));
            }
        } elseif ("disabled" === $status) {
            $locale = new AppLocale($appname);
            $locale->setEnabled(false);
            $locale->apply();
            unset($locale);
            $locale = new AppLocale($appname);
            if (false === $locale->isEnabled()) {
                return ((new Renderer())->jsonRenderer(array("code" => 200, "msg" => "OK")));
            } else {
                return ((new Renderer())->jsonRenderer(array("code" => 500,
                    "results" => "Cannot disabled app locale for $appname")));
            }
        }
        return ((new Renderer())->jsonRenderer(array("code" => 500,
            "results" => "Undefined locale status $status")));
    }
1120052
public function switchToWindow($name = null) {
    $handles = $this->browser->windowHandles();
    if ($name === null) {
      //null means back to the main window
      return $this->browser->switchToWindow($handles[0]);
    }

    $windowHandle = $this->browser->windowHandle($name);
    if (!empty($windowHandle)) {
      $this->browser->switchToWindow($windowHandle);
    } else {
      throw new DriverException("Could not find window handle by a given window name: $name");
    }

  }
254611
final public function get(string $name)
    {
        $service_selected = null;
        foreach ($this->services as $one => $val) {
            if ($val['name'] === $name) {
                if (!in_array($val['content']->status, array("enabled", "disabled"))) {
                    throw new Server500(new \ArrayObject(array("explain" =>
                        "Undefined status [ ".$val['content']->status." ] for ".$val['name']." service",
                        "solution" => "Please set the status [disabled] or [enabled]")));
                }
                if ($val['content']->status == "disabled") {
                    throw new Server500(new \ArrayObject(array("explain" =>
                        "The service [ ".$val['name']." ] is currently disabled ",
                        "solution" => "Please set the status [enabled] to enable the service")));
                }
                $i = $val['content']->namespace;
                $container = FrameworkContainer::getInstance();
                return ($container->get($i));
            }
        }

        throw new Server500(new \ArrayObject(array("explain" =>
            "Undefined service : $name", "solution" => "Please register the [$name] service")));
    }
955911
public static function override(string $name, \Closure $closure, string $appName = null) : ServiceLocator
    {
        $service = self::determineService($appName);
        if (isset($service[$name])) {
            unset($service[$name]);
        }
        $service[$name] = $closure;
        return $service;
    }
1053701
public function CheckRequirements($ApplicationName) {
      $AvailableApplications = $this->AvailableApplications();
      $RequiredApplications = ArrayValue('RequiredApplications', ArrayValue($ApplicationName, $AvailableApplications, array()), FALSE);
      $EnabledApplications = $this->EnabledApplications();
      CheckRequirements($ApplicationName, $RequiredApplications, $EnabledApplications, 'application');
   }
406237
public function findRepository(string $appName): ? AppRepository
    {
        return isset($this->repositories[$appName])
            ? $this->repositories[$appName]
            : null;
    }
639080
public function createAdminConfiguration(
        string $adminName,
        array $configuration,
        ApplicationConfiguration $applicationConfiguration
    ): AdminConfiguration {
        $event = new ConfigurationEvent($adminName, $configuration, $adminName, $configuration['entity']);
        $this->eventDispatcher->dispatch(Events::CONFIGURATION_ADMIN, $event);

        $resolver = new OptionsResolver();
        $adminConfiguration = new AdminConfiguration($applicationConfiguration);
        $adminConfiguration->configureOptions($resolver);
        $adminConfiguration->setParameters($resolver->resolve($event->getConfiguration()));

        return $adminConfiguration;
    }