mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-28 06:56:05 +00:00
refactoring
This commit is contained in:
@@ -104,21 +104,15 @@ class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an application is installed.
|
||||
* Whether the application is installed.
|
||||
*/
|
||||
public function isInstalled(): bool
|
||||
{
|
||||
$config = $this->getConfig();
|
||||
|
||||
if (file_exists($config->getConfigPath()) && $config->get('isInstalled')) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
return $this->getConfig()->get('isInstalled');
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a service container.
|
||||
* Get the service container.
|
||||
*/
|
||||
public function getContainer(): Container
|
||||
{
|
||||
|
||||
@@ -32,6 +32,7 @@ namespace Espo\Core\ApplicationRunners;
|
||||
use Espo\Core\{
|
||||
Application\Runner,
|
||||
Utils\ClientManager,
|
||||
Utils\Config,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -41,13 +42,22 @@ class Client implements Runner
|
||||
{
|
||||
private $clientManager;
|
||||
|
||||
public function __construct(ClientManager $clientManager)
|
||||
private $config;
|
||||
|
||||
public function __construct(ClientManager $clientManager, Config $config)
|
||||
{
|
||||
$this->clientManager = $clientManager;
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
if (!$this->config->get('isInstalled')) {
|
||||
header("Location: install/");
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->clientManager->display();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,7 +163,10 @@ class ContainerBuilder
|
||||
$bindingContainer = new BindingContainer($bindingLoader->load());
|
||||
|
||||
return new $this->containerClassName(
|
||||
$this->containerConfigurationClassName, $this->loaderClassNames, $this->services, $bindingContainer
|
||||
$this->containerConfigurationClassName,
|
||||
$this->loaderClassNames,
|
||||
$this->services,
|
||||
$bindingContainer
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,7 +52,7 @@ class Client implements Runner
|
||||
|
||||
public function run(): void
|
||||
{
|
||||
$portalId = $this->applicationState->getPortal()->id;
|
||||
$portalId = $this->applicationState->getPortal()->getId();
|
||||
|
||||
$this->clientManager->display(null, null, [
|
||||
'portalId' => $portalId,
|
||||
|
||||
@@ -33,9 +33,11 @@ class Url
|
||||
{
|
||||
public static function detectPortalIdForApi(): ?string
|
||||
{
|
||||
if (!empty($_GET['portalId'])) {
|
||||
return $_GET['portalId'];
|
||||
}
|
||||
$portalId = filter_input(INPUT_GET, 'portalId');
|
||||
|
||||
if ($portalId) {
|
||||
return $portalId;
|
||||
}
|
||||
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
|
||||
@@ -90,9 +92,7 @@ class Url
|
||||
return false;
|
||||
}
|
||||
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
|
||||
$a = explode('?', $url);
|
||||
$a = explode('?', $_SERVER['REQUEST_URI']);
|
||||
|
||||
$url = rtrim($a[0], '/');
|
||||
|
||||
|
||||
@@ -34,7 +34,7 @@ use Espo\Core\{
|
||||
Utils\Config\ConfigFileManager,
|
||||
};
|
||||
|
||||
use StdClass;
|
||||
use stdClass;
|
||||
use E_USER_DEPRECATED;
|
||||
|
||||
/**
|
||||
@@ -91,16 +91,22 @@ class Config
|
||||
|
||||
$lastBranch = $this->loadConfig();
|
||||
|
||||
foreach ($keys as $keyName) {
|
||||
if (isset($lastBranch[$keyName]) && (is_array($lastBranch) || is_object($lastBranch))) {
|
||||
if (is_array($lastBranch)) {
|
||||
$lastBranch = $lastBranch[$keyName];
|
||||
} else {
|
||||
$lastBranch = $lastBranch->$keyName;
|
||||
}
|
||||
} else {
|
||||
foreach ($keys as $key) {
|
||||
if (!is_array($lastBranch) && !is_object($lastBranch)) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (!isset($lastBranch[$key])) {
|
||||
return $default;
|
||||
}
|
||||
|
||||
if (is_array($lastBranch)) {
|
||||
$lastBranch = $lastBranch[$key];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$lastBranch = $lastBranch->$key;
|
||||
}
|
||||
|
||||
return $lastBranch;
|
||||
@@ -115,16 +121,22 @@ class Config
|
||||
|
||||
$lastBranch = $this->loadConfig();
|
||||
|
||||
foreach ($keys as $keyName) {
|
||||
if (isset($lastBranch[$keyName]) && (is_array($lastBranch) || is_object($lastBranch))) {
|
||||
if (is_array($lastBranch)) {
|
||||
$lastBranch = $lastBranch[$keyName];
|
||||
} else {
|
||||
$lastBranch = $lastBranch->$keyName;
|
||||
}
|
||||
} else {
|
||||
foreach ($keys as $key) {
|
||||
if (!is_array($lastBranch) && !is_object($lastBranch)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!isset($lastBranch[$key])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (is_array($lastBranch)) {
|
||||
$lastBranch = $lastBranch[$key];
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
$lastBranch = $lastBranch->$key;
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -269,8 +281,8 @@ class Config
|
||||
}
|
||||
|
||||
$configPath = $this->fileManager->isFile($this->configPath) ?
|
||||
$this->configPath :
|
||||
$this->defaultConfigPath;
|
||||
$this->configPath :
|
||||
$this->defaultConfigPath;
|
||||
|
||||
$this->data = $this->fileManager->getPhpContents($configPath);
|
||||
|
||||
@@ -286,7 +298,7 @@ class Config
|
||||
/**
|
||||
* Get all parameters.
|
||||
*/
|
||||
public function getAllData(): StdClass
|
||||
public function getAllData(): stdClass
|
||||
{
|
||||
return (object) $this->loadConfig();
|
||||
}
|
||||
|
||||
@@ -37,13 +37,7 @@ use Espo\Core\{
|
||||
|
||||
$app = new Application();
|
||||
|
||||
if (!$app->isInstalled()) {
|
||||
header("Location: install/");
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
if (!empty($_GET['entryPoint'])) {
|
||||
if (filter_has_var(INPUT_GET, 'entryPoint')) {
|
||||
$app->run(EntryPoint::class);
|
||||
|
||||
exit;
|
||||
|
||||
@@ -53,14 +53,12 @@ if (Url::detectIsInPortalDir()) {
|
||||
$app->setClientBasePath($basePath);
|
||||
}
|
||||
|
||||
if (!empty($_GET['entryPoint'])) {
|
||||
if (filter_has_var(INPUT_GET, 'entryPoint')) {
|
||||
$app->run(EntryPoint::class);
|
||||
|
||||
exit;
|
||||
}
|
||||
|
||||
$params = RunnerParams::fromArray([
|
||||
'basePath' => $basePath,
|
||||
]);
|
||||
$params = RunnerParams::create()->with('basePath', $basePath);
|
||||
|
||||
$app->run(PortalClient::class, $params);
|
||||
|
||||
Reference in New Issue
Block a user