mirror of
https://github.com/espocrm/espocrm.git
synced 2026-06-27 22:46:04 +00:00
application runners and fixes
This commit is contained in:
@@ -161,19 +161,10 @@ class Application
|
||||
$slim->run();
|
||||
}
|
||||
|
||||
/**
|
||||
* Display the main HTML page.
|
||||
*/
|
||||
public function runClient()
|
||||
{
|
||||
$this->getClientManager()->display();
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run entryPoint.
|
||||
*/
|
||||
public function runEntryPoint(string $entryPoint, array $data = [], bool $final = false)
|
||||
public function runEntryPoint(string $entryPoint, $data = null, bool $final = false)
|
||||
{
|
||||
if (empty($entryPoint)) {
|
||||
throw new Error();
|
||||
@@ -280,7 +271,7 @@ class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether the application is installed.
|
||||
* Whether an application is installed.
|
||||
*/
|
||||
public function isInstalled() : bool
|
||||
{
|
||||
@@ -294,7 +285,7 @@ class Application
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the service container.
|
||||
* Get a service container.
|
||||
*/
|
||||
public function getContainer() : Container
|
||||
{
|
||||
|
||||
52
application/Espo/Core/ApplicationRunners/Client.php
Normal file
52
application/Espo/Core/ApplicationRunners/Client.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\ApplicationRunners;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\ClientManager,
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the main HTML page.
|
||||
*/
|
||||
class Client implements ApplicationRunner
|
||||
{
|
||||
protected $clientManager;
|
||||
|
||||
public function __construct(ClientManager $clientManager)
|
||||
{
|
||||
$this->clientManager = $clientManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$this->clientManager->display();
|
||||
}
|
||||
}
|
||||
@@ -38,6 +38,8 @@ use Espo\Core\{
|
||||
Api\Response,
|
||||
};
|
||||
|
||||
use StdClass;
|
||||
|
||||
/**
|
||||
* Runs entry points.
|
||||
*/
|
||||
@@ -77,7 +79,7 @@ class EntryPointManager
|
||||
return $className::$notStrictAuth ?? false;
|
||||
}
|
||||
|
||||
public function run(string $name, Request $request, Response $response, array $data = [])
|
||||
public function run(string $name, Request $request, Response $response, ?StdClass $data = null)
|
||||
{
|
||||
$className = $this->getClassName($name);
|
||||
if (!$className) {
|
||||
|
||||
@@ -121,17 +121,6 @@ class Application extends BaseApplication
|
||||
return parent::getRunnerClassName($runnerName);
|
||||
}
|
||||
|
||||
public function runClient()
|
||||
{
|
||||
$this->container->get('clientManager')->display(null, null, [
|
||||
'portalId' => $this->getPortal()->id,
|
||||
'applicationId' => $this->getPortal()->id,
|
||||
'apiUrl' => 'api/v1/portal-access/' . $this->getPortal()->id,
|
||||
'appClientClassName' => 'app-portal'
|
||||
]);
|
||||
exit;
|
||||
}
|
||||
|
||||
protected function initPreloads()
|
||||
{
|
||||
parent::initPreloads();
|
||||
|
||||
63
application/Espo/Core/Portal/ApplicationRunners/Client.php
Normal file
63
application/Espo/Core/Portal/ApplicationRunners/Client.php
Normal file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM - Open Source CRM application.
|
||||
* Copyright (C) 2014-2020 Yuri Kuznetsov, Taras Machyshyn, Oleksiy Avramenko
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* EspoCRM is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* EspoCRM is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with EspoCRM. If not, see http://www.gnu.org/licenses/.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\Core\Portal\ApplicationRunners;
|
||||
|
||||
use Espo\Core\{
|
||||
Utils\ClientManager,
|
||||
ApplicationState,
|
||||
ApplicationRunners\ApplicationRunner,
|
||||
};
|
||||
|
||||
/**
|
||||
* Displays the main HTML page for a portal.
|
||||
*/
|
||||
class Client implements ApplicationRunner
|
||||
{
|
||||
protected $clientManager;
|
||||
protected $applicationState;
|
||||
|
||||
public function __construct(ClientManager $clientManager, ApplicationState $applicationState)
|
||||
{
|
||||
$this->clientManager = $clientManager;
|
||||
$this->applicationState = $applicationState;
|
||||
}
|
||||
|
||||
public function run()
|
||||
{
|
||||
$portalId = $this->applicationState->getPortal()->id;
|
||||
|
||||
$this->clientManager->display(null, null, [
|
||||
'portalId' => $portalId,
|
||||
'applicationId' => $portalId,
|
||||
'apiUrl' => 'api/v1/portal-access/' . $portalId,
|
||||
'appClientClassName' => 'app-portal',
|
||||
]);
|
||||
}
|
||||
}
|
||||
@@ -36,6 +36,8 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\EntryPoints\EntryPoint;
|
||||
use Espo\Core\Di;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
class Attachment implements EntryPoint,
|
||||
Di\EntityManagerAware,
|
||||
Di\AclAware
|
||||
@@ -50,7 +52,7 @@ class Attachment implements EntryPoint,
|
||||
'image/webp',
|
||||
];
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ use Espo\Core\Exceptions\Error;
|
||||
use Espo\Core\EntryPoints\NotStrictAuth;
|
||||
use Espo\Core\Di;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
class Avatar extends Image implements Di\MetadataAware
|
||||
{
|
||||
use Di\MetadataSetter;
|
||||
@@ -71,7 +73,7 @@ class Avatar extends Image implements Di\MetadataAware
|
||||
return $colorList[$index];
|
||||
}
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$userId = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
@@ -42,6 +42,7 @@ use Espo\Core\{
|
||||
Utils\Config,
|
||||
Utils\ClientManager,
|
||||
ORM\EntityManager,
|
||||
Api\Request,
|
||||
};
|
||||
|
||||
class ChangePassword implements EntryPoint
|
||||
@@ -59,7 +60,7 @@ class ChangePassword implements EntryPoint
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$requestId = $request->get('id');
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ use Espo\Core\EntryPoints\{
|
||||
use Espo\Core\{
|
||||
Utils\ClientManager,
|
||||
ServiceFactory,
|
||||
Api\Request,
|
||||
};
|
||||
|
||||
class ConfirmOptIn implements EntryPoint
|
||||
@@ -57,7 +58,7 @@ class ConfirmOptIn implements EntryPoint
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@ use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
};
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
class Download implements EntryPoint
|
||||
{
|
||||
protected $fileTypesToShowInline = [
|
||||
@@ -64,7 +66,7 @@ class Download implements EntryPoint
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
|
||||
|
||||
@@ -36,6 +36,9 @@ use Espo\Core\Exceptions\BadRequest;
|
||||
use Espo\Core\Exceptions\Error;
|
||||
|
||||
use Espo\Core\EntryPoints\EntryPoint;
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
class Image implements EntryPoint,
|
||||
@@ -73,7 +76,7 @@ class Image implements EntryPoint,
|
||||
|
||||
protected $allowedFieldList = null;
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
@@ -38,6 +38,8 @@ use Espo\Core\EntryPoints\{
|
||||
NoAuth,
|
||||
};
|
||||
|
||||
use Espo\Core\Api\Request;
|
||||
|
||||
use Espo\Core\Di;
|
||||
|
||||
class LogoImage extends Image implements Di\ConfigAware
|
||||
@@ -49,7 +51,7 @@ class LogoImage extends Image implements Di\ConfigAware
|
||||
|
||||
protected $allowedFieldList = ['companyLogo'];
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
@@ -39,6 +39,7 @@ use Espo\Core\EntryPoints\{
|
||||
use Espo\Core\{
|
||||
ORM\EntityManager,
|
||||
ServiceFactory,
|
||||
Api\Request,
|
||||
};
|
||||
|
||||
class Pdf implements EntryPoint
|
||||
@@ -52,7 +53,7 @@ class Pdf implements EntryPoint
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run($request)
|
||||
public function run(Request $request)
|
||||
{
|
||||
$entityId = $request->get('entityId');
|
||||
$entityType = $request->get('entityType');
|
||||
|
||||
@@ -40,8 +40,12 @@ use Espo\Core\{
|
||||
Utils\ClientManager,
|
||||
Utils\Config,
|
||||
Portal\Application as PortalApplication,
|
||||
Api\Request,
|
||||
Api\Response,
|
||||
};
|
||||
|
||||
use StdClass;
|
||||
|
||||
class Portal implements EntryPoint
|
||||
{
|
||||
use NoAuth;
|
||||
@@ -55,9 +59,11 @@ class Portal implements EntryPoint
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run($request, $response, $data = [])
|
||||
public function run(Request $request, Response $response, ?StdClass $data = null)
|
||||
{
|
||||
$id = $request->get('id') ?? $data['id'] ?? null;
|
||||
$data = $data ?? (object) [];
|
||||
|
||||
$id = $request->get('id') ?? $data->id ?? null;
|
||||
|
||||
if (!$id) {
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
@@ -78,6 +84,6 @@ class Portal implements EntryPoint
|
||||
|
||||
$application = new PortalApplication($id);
|
||||
$application->setClientBasePath($this->clientManager->getBasePath());
|
||||
$application->runClient();
|
||||
$application->run('client');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user