entry point changes
This commit is contained in:
@@ -126,8 +126,10 @@ class Application
|
||||
$apiAuth = new ApiAuth($auth, $authRequired, true);
|
||||
$slim->add($apiAuth);
|
||||
|
||||
$slim->hook('slim.before.dispatch', function () use ($entryPoint, $entryPointManager, $container, $data) {
|
||||
$entryPointManager->run($entryPoint, $data);
|
||||
$request = $slim->request();
|
||||
|
||||
$slim->hook('slim.before.dispatch', function () use ($entryPointManager, $entryPoint, $request, $data) {
|
||||
$entryPointManager->run($entryPoint, $request, $data);
|
||||
});
|
||||
|
||||
$slim->run();
|
||||
|
||||
@@ -38,9 +38,12 @@ use Espo\Core\{
|
||||
EntryPoints\NoAuth,
|
||||
};
|
||||
|
||||
use Slim\Http\Request;
|
||||
|
||||
class EntryPointManager
|
||||
{
|
||||
private $injectableFactory;
|
||||
protected $injectableFactory;
|
||||
protected $classFinder;
|
||||
|
||||
public function __construct(InjectableFactory $injectableFactory, ClassFinder $classFinder)
|
||||
{
|
||||
@@ -80,7 +83,7 @@ class EntryPointManager
|
||||
return $className::$notStrictAuth ?? false;
|
||||
}
|
||||
|
||||
public function run(string $name, array $data = [])
|
||||
public function run(string $name, Request $request, array $data = [])
|
||||
{
|
||||
$className = $this->getClassName($name);
|
||||
if (!$className) {
|
||||
@@ -89,7 +92,7 @@ class EntryPointManager
|
||||
|
||||
$entryPoint = $this->injectableFactory->create($className);
|
||||
|
||||
$entryPoint->run($data);
|
||||
$entryPoint->run($request, $data);
|
||||
}
|
||||
|
||||
protected function getClassName(string $name) : ?string
|
||||
|
||||
@@ -71,14 +71,15 @@ class Avatar extends Image implements NotStrictAuth,
|
||||
return $colorList[$index];
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['id'])) {
|
||||
$userId = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
if (!$userId) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$userId = $_GET['id'];
|
||||
|
||||
$user = $this->entityManager->getEntity('User', $userId);
|
||||
if (!$user) {
|
||||
header('Content-Type: image/png');
|
||||
@@ -94,11 +95,6 @@ class Avatar extends Image implements NotStrictAuth,
|
||||
|
||||
$id = $user->get('avatarId');
|
||||
|
||||
$size = null;
|
||||
if (!empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
}
|
||||
|
||||
if (!empty($id)) {
|
||||
$this->show($id, $size, true);
|
||||
} else {
|
||||
|
||||
@@ -57,9 +57,9 @@ class ChangePassword implements EntryPoint, NoAuth
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$requestId = $_GET['id'] ?? null;
|
||||
$requestId = $request->get('id');
|
||||
|
||||
if (!$requestId) throw new BadRequest();
|
||||
|
||||
|
||||
@@ -55,11 +55,11 @@ class ConfirmOptIn implements EntryPoint, NoAuth
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['id'])) throw new BadRequest();
|
||||
$id = $request->get('id');
|
||||
|
||||
$id = $_GET['id'];
|
||||
if (!$id) throw new BadRequest();
|
||||
|
||||
$data = $this->serviceFactory->create('LeadCapture')->confirmOptIn($id);
|
||||
|
||||
|
||||
@@ -65,12 +65,11 @@ class Download implements EntryPoint
|
||||
$this->entityManager = $entityManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $_GET['id'];
|
||||
$id = $request->get('id');
|
||||
|
||||
if (!$id) throw new BadRequest();
|
||||
|
||||
$attachment = $this->entityManager->getEntity('Attachment', $id);
|
||||
|
||||
|
||||
@@ -73,16 +73,13 @@ class Image implements EntryPoint,
|
||||
|
||||
protected $allowedFieldList = null;
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $_GET['id'];
|
||||
$id = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
$size = null;
|
||||
if (!empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
if (!$id) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
|
||||
$this->show($id, $size, false);
|
||||
|
||||
@@ -49,25 +49,21 @@ class LogoImage extends Image implements NoAuth,
|
||||
|
||||
protected $allowedFieldList = ['companyLogo'];
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$id = $request->get('id');
|
||||
$size = $request->get('size') ?? null;
|
||||
|
||||
$this->imageSizes['small-logo'] = [181, 44];
|
||||
|
||||
if (!empty($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
} else {
|
||||
if (!$id) {
|
||||
$id = $this->config->get('companyLogoId');
|
||||
}
|
||||
|
||||
if (empty($id)) {
|
||||
if (!$id) {
|
||||
throw new NotFound();
|
||||
}
|
||||
|
||||
$size = null;
|
||||
if (!empty($_GET['size'])) {
|
||||
$size = $_GET['size'];
|
||||
}
|
||||
|
||||
$this->show($id, $size);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -52,14 +52,15 @@ class Pdf implements EntryPoint
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['entityId']) || empty($_GET['entityType']) || empty($_GET['templateId'])) {
|
||||
$entityId = $request->get('entityId');
|
||||
$entityType = $request->get('entityType');
|
||||
$templateId = $request->get('templateId');
|
||||
|
||||
if (!$entityId || !$entityType || !$templateId) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$entityId = $_GET['entityId'];
|
||||
$entityType = $_GET['entityType'];
|
||||
$templateId = $_GET['templateId'];
|
||||
|
||||
$entity = $this->entityManager->getEntity($entityType, $entityId);
|
||||
$template = $this->entityManager->getEntity('Template', $templateId);
|
||||
|
||||
@@ -53,13 +53,11 @@ class Portal implements EntryPoint, NoAuth
|
||||
$this->config = $config;
|
||||
}
|
||||
|
||||
public function run($data = [])
|
||||
public function run($request, $data = [])
|
||||
{
|
||||
if (!empty($_GET['id'])) {
|
||||
$id = $_GET['id'];
|
||||
} else if (!empty($data['id'])) {
|
||||
$id = $data['id'];
|
||||
} else {
|
||||
$id = $request->get('id') ?? $data['id'] ?? null;
|
||||
|
||||
if (!$id) {
|
||||
$url = $_SERVER['REQUEST_URI'];
|
||||
$id = explode('/', $url)[count(explode('/', $_SERVER['SCRIPT_NAME'])) - 1];
|
||||
|
||||
|
||||
@@ -57,13 +57,12 @@ class CampaignTrackOpened implements EntryPoint, NoAuth
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
if (empty($_GET['id'])) {
|
||||
throw new BadRequest();
|
||||
}
|
||||
$id = $request->get('id');
|
||||
if (!$id) throw new BadRequest();
|
||||
|
||||
$queueItemId = $_GET['id'];
|
||||
$queueItemId = $id;
|
||||
|
||||
$queueItem = $this->entityManager->getEntity('EmailQueueItem', $queueItemId);
|
||||
|
||||
|
||||
@@ -73,12 +73,12 @@ class CampaignUrl implements EntryPoint, NoAuth
|
||||
$this->metadata = $metadata;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$queueItemId = $_GET['queueItemId'] ?? null;
|
||||
$trackingUrlId = $_GET['id'] ?? null;
|
||||
$emailAddress = $_GET['emailAddress'] ?? null;
|
||||
$hash = $_GET['hash'] ?? null;
|
||||
$queueItemId = $request->get('queueItemId') ?? null;
|
||||
$trackingUrlId = $request->get('id') ?? null;
|
||||
$emailAddress = $request->get('emailAddress') ?? null;
|
||||
$hash = $request->get('hash') ?? null;
|
||||
|
||||
if (!$trackingUrlId) throw new Exceptions\BadRequest();
|
||||
$trackingUrl = $this->entityManager->getEntity('CampaignTrackingUrl', $trackingUrlId);
|
||||
|
||||
@@ -59,10 +59,10 @@ class EventConfirmation implements EntryPoint, NoAuth
|
||||
$this->hookManager = $hookManager;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$uid = $_GET['uid'] ?? null;
|
||||
$action = $_GET['action'] ?? null;
|
||||
$uid = $request->get('uid') ?? null;
|
||||
$action = $request->get('action') ?? null;
|
||||
|
||||
if (empty($uid) || empty($action)) {
|
||||
throw new BadRequest();
|
||||
|
||||
@@ -75,11 +75,11 @@ class SubscribeAgain implements EntryPoint, NoAuth
|
||||
$this->hasher = $hasher;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$id = $_GET['id'] ?? null;
|
||||
$emailAddress = $_GET['emailAddress'] ?? null;
|
||||
$hash = $_GET['hash'] ?? null;
|
||||
$id = $request->get('id') ?? null;
|
||||
$emailAddress = $request->get('emailAddress') ?? null;
|
||||
$hash = $request->get('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
@@ -79,11 +79,11 @@ class Unsubscribe implements EntryPoint, NoAuth
|
||||
$this->serviceFactory = $serviceFactory;
|
||||
}
|
||||
|
||||
public function run()
|
||||
public function run($request)
|
||||
{
|
||||
$id = $_GET['id'] ?? null;
|
||||
$emailAddress = $_GET['emailAddress'] ?? null;
|
||||
$hash = $_GET['hash'] ?? null;
|
||||
$id = $request->get('id') ?? null;
|
||||
$emailAddress = $request->get('emailAddress') ?? null;
|
||||
$hash = $request->get('hash') ?? null;
|
||||
|
||||
if ($emailAddress && $hash) {
|
||||
$this->processWithHash($emailAddress, $hash);
|
||||
|
||||
Reference in New Issue
Block a user