diff --git a/api/v1/portal/index.php b/api/v1/portal/index.php index 58e67273a2..bbd6613cfb 100644 --- a/api/v1/portal/index.php +++ b/api/v1/portal/index.php @@ -29,7 +29,11 @@ require_once('../../../bootstrap.php'); -$portalId = explode('/', $_SERVER['REQUEST_URI'])[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; +if (!empty($_GET['portalId'])) { + $portalId = $_GET['portalId']; +} else { + $portalId = explode('/', $_SERVER['REQUEST_URI'])[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1]; +} $app = new \Espo\Core\Portal\Application($portalId); $app->run(); diff --git a/application/Espo/Core/Application.php b/application/Espo/Core/Application.php index d7ad9023fc..c159f529fc 100644 --- a/application/Espo/Core/Application.php +++ b/application/Espo/Core/Application.php @@ -102,8 +102,7 @@ class Application $slim = $this->getSlim(); $container = $this->getContainer(); - $slim->get('/', function() {}); - $slim->post('/', function() {}); + $slim->any('.*', function() {}); $entryPointManager = new \Espo\Core\EntryPointManager($container); diff --git a/application/Espo/Core/Utils/Api/Slim.php b/application/Espo/Core/Utils/Api/Slim.php index 7f6ee960ee..6feabb2b12 100644 --- a/application/Espo/Core/Utils/Api/Slim.php +++ b/application/Espo/Core/Utils/Api/Slim.php @@ -39,33 +39,19 @@ class Slim extends \Slim\Slim */ public function run() { - //set_error_handler(array('\Slim\Slim', 'handleErrors')); //Espo: no needs to use this handler - - //Apply final outer middleware layers - if ($this->config('debug')) { - //Apply pretty exceptions only in debug to avoid accidental information leakage in production - //$this->add(new \Slim\Middleware\PrettyExceptions()); //Espo: no needs to use this handler - } - - //Invoke middleware and application stack $this->middleware[0]->call(); - //Fetch status, header, and body list($status, $headers, $body) = $this->response->finalize(); - // Serialize cookies (with optional encryption) \Slim\Http\Util::serializeCookies($headers, $this->response->cookies, $this->settings); - //Send headers if (headers_sent() === false) { - //Send status if (strpos(PHP_SAPI, 'cgi') === 0) { header(sprintf('Status: %s', \Slim\Http\Response::getMessageForCode($status))); } else { header(sprintf('HTTP/%s %s', $this->config('http.version'), \Slim\Http\Response::getMessageForCode($status))); } - //Send headers foreach ($headers as $name => $value) { $hValues = explode("\n", $value); foreach ($hValues as $hVal) { @@ -74,12 +60,9 @@ class Slim extends \Slim\Slim } } - //Send body, but only if it isn't a HEAD request if (!$this->request->isHead()) { echo $body; } - - //restore_error_handler(); //Espo: no needs to use this handler } public function printError($error, $status) @@ -87,5 +70,4 @@ class Slim extends \Slim\Slim echo static::generateTemplateMarkup($status, '
'.$error.'
Visit the Home Page'); } - } \ No newline at end of file diff --git a/application/Espo/Services/Portal.php b/application/Espo/Services/Portal.php index afed86bb18..7761459ccc 100644 --- a/application/Espo/Services/Portal.php +++ b/application/Espo/Services/Portal.php @@ -50,12 +50,13 @@ class Portal extends Record protected function loadUrlField(Entity $entity) { $siteUrl = $this->getConfig()->get('siteUrl'); - $url = $siteUrl . '?entryPoint=portal'; + $siteUrl = rtrim($siteUrl , '/') . '/'; + $url = $siteUrl . 'portal'; if ($entity->id === $this->getConfig()->get('defaultPortalId')) { $entity->set('isDefault', true); $entity->setFetched('isDefault', true); } else { - $url .= '&id=' . $entity->id; + $url .= '?id=' . $entity->id; $entity->setFetched('isDefault', false); } $entity->set('url', $url);