exceptions

This commit is contained in:
Yuri Kuznetsov
2022-06-24 11:06:01 +03:00
parent 503e1f6eff
commit 2ecfdc2d4b
38 changed files with 254 additions and 47 deletions

View File

@@ -160,7 +160,6 @@ class Application
/**
* Setup the system user. The system user is used when no user is logged in.
* @throws Exceptions\Error
*/
public function setupSystemUser(): void
{

View File

@@ -408,6 +408,8 @@ class LDAP implements Login
/**
* Find LDAP user DN by his username.
*
* @throws \Laminas\Ldap\Exception\LdapException
*/
private function findLdapUserDnByUsername(string $username): ?string
{

View File

@@ -302,6 +302,9 @@ class Upgrade implements Command
return $upgradeId;
}
/**
* @throws Error
*/
private function runUpgradeProcess(string $upgradeId, ?stdClass $params = null): void
{
$params = $params ?? (object) [];
@@ -324,6 +327,7 @@ class Upgrade implements Command
/**
* @param string[] $stepList
* @throws Error
*/
private function runStepsInSingleProcess(string $upgradeId, array $stepList): void
{
@@ -350,6 +354,7 @@ class Upgrade implements Command
/**
* @param string[] $stepList
* @throws Error
*/
private function runSteps(string $upgradeId, array $stepList): void
{

View File

@@ -31,6 +31,9 @@ namespace Espo\Core\Controllers;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Api\Request;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\NotFoundSilent;
use Espo\Core\Select\SearchParams;
use Espo\Core\Utils\Json;
@@ -40,6 +43,10 @@ class Record extends RecordBase
{
/**
* List related records.
*
* @throws BadRequest
* @throws NotFound
* @throws Forbidden
*/
public function getActionListLinked(Request $request): stdClass
{
@@ -66,6 +73,10 @@ class Record extends RecordBase
/**
* Relate records.
*
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionCreateLink(Request $request): bool
{
@@ -108,7 +119,11 @@ class Record extends RecordBase
}
/**
* Unrelate records.
* Un-relate records.
*
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function deleteActionRemoveLink(Request $request): bool
{
@@ -146,6 +161,10 @@ class Record extends RecordBase
/**
* Follow a record.
*
* @throws BadRequest
* @throws NotFoundSilent
* @throws Forbidden
*/
public function putActionFollow(Request $request): bool
{
@@ -162,6 +181,9 @@ class Record extends RecordBase
/**
* Unfollow a record.
*
* @throws NotFoundSilent
* @throws BadRequest
*/
public function deleteActionUnfollow(Request $request): bool
{
@@ -176,6 +198,9 @@ class Record extends RecordBase
return true;
}
/**
* @throws BadRequest
*/
private function fetchMassLinkSearchParamsFromRequest(Request $request): SearchParams
{
$data = $request->getParsedBody();

View File

@@ -32,6 +32,9 @@ namespace Espo\Core\Controllers;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\ForbiddenSilent;
use Espo\Core\Exceptions\NotFound;
use Espo\Core\Exceptions\NotFoundSilent;
use Espo\Core\Record\ServiceContainer as RecordServiceContainer;
use Espo\Core\Record\SearchParamsFetcher;
use Espo\Core\Record\CreateParamsFetcher;
@@ -163,6 +166,10 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
/**
* Read a record.
*
* @throws NotFoundSilent
* @throws ForbiddenSilent
* @throws BadRequest
*/
public function getActionRead(Request $request, Response $response): stdClass
{
@@ -185,6 +192,10 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
/**
* Create a record.
*
* @throws Forbidden
* @throws \Espo\Core\Exceptions\Conflict
* @throws BadRequest
*/
public function postActionCreate(Request $request, Response $response): stdClass
{
@@ -201,6 +212,12 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
return $entity->getValueMap();
}
/**
* @throws BadRequest
* @throws NotFound
* @throws Forbidden
* @throws \Espo\Core\Exceptions\Conflict
*/
public function patchActionUpdate(Request $request, Response $response): stdClass
{
return $this->putActionUpdate($request, $response);
@@ -208,6 +225,11 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
/**
* Update a record.
*
* @throws BadRequest
* @throws NotFound
* @throws Forbidden
* @throws \Espo\Core\Exceptions\Conflict
*/
public function putActionUpdate(Request $request, Response $response): stdClass
{
@@ -232,6 +254,8 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
/**
* List records.
*
* @throws Forbidden
*/
public function getActionList(Request $request, Response $response): stdClass
{
@@ -253,6 +277,10 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
/**
* Delete a record.
*
* @throws Forbidden
* @throws BadRequest
* @throws NotFound
*/
public function deleteActionDelete(Request $request, Response $response): bool
{
@@ -278,6 +306,12 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
return $this->searchParamsFetcher->fetch($request);
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
* @throws ForbiddenSilent
*/
public function postActionGetDuplicateAttributes(Request $request): stdClass
{
$id = $request->getParsedBody()->id ?? null;
@@ -289,6 +323,11 @@ class RecordBase extends Base implements Di\EntityManagerAware, Di\InjectableFac
return $this->getRecordService()->getDuplicateAttributes($id);
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function postActionRestoreDeleted(Request $request): bool
{
if (!$this->user->isAdmin()) {

View File

@@ -47,6 +47,11 @@ class RecordTree extends Record
/**
* Get a category tree.
*
* @throws BadRequest
* @throws Error
* @throws Forbidden
* @throws \Espo\Core\Exceptions\NotFound
*/
public function getActionListTree(Request $request): stdClass
{

View File

@@ -72,6 +72,7 @@ class Evaluator
/**
* @return mixed
* @throws Exceptions\Error
*/
public function process(string $expression, ?Entity $entity = null, ?stdClass $variables = null)
{

View File

@@ -67,6 +67,7 @@ class FunctionFactory
/**
* @return \Espo\Core\Formula\Functions\BaseFunction|\Espo\Core\Formula\Functions\Base
* @throws UnknownFunction
*/
public function create(string $name, ?Entity $entity = null, ?stdClass $variables = null): object
{

View File

@@ -126,6 +126,7 @@ abstract class Base implements Injectable
/**
* @return mixed
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public abstract function process(stdClass $item);

View File

@@ -90,6 +90,7 @@ abstract class BaseFunction
* Evaluates a function.
*
* @return mixed A result of the function.
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public abstract function process(ArgumentList $args);

View File

@@ -52,6 +52,8 @@ class DiffType extends BaseFunction
/**
* @return ?int
* @throws \Espo\Core\Formula\Exceptions\TooFewArguments
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(ArgumentList $args)
{

View File

@@ -47,6 +47,8 @@ class GetLinkColumnType extends \Espo\Core\Formula\Functions\Base implements
/**
* @return mixed
* @throws Error
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(\stdClass $item)
{

View File

@@ -35,6 +35,8 @@ class HasLinkMultipleIdType extends \Espo\Core\Formula\Functions\Base
{
/**
* @return bool
* @throws Error
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(\stdClass $item)
{

View File

@@ -35,6 +35,8 @@ class IsAttributeChangedType extends \Espo\Core\Formula\Functions\Base
{
/**
* @return bool
* @throws Error
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(\stdClass $item)
{
@@ -50,6 +52,7 @@ class IsAttributeChangedType extends \Espo\Core\Formula\Functions\Base
/**
* @param string $attribute
* @return bool
* @throws Error
*/
protected function check($attribute)
{

View File

@@ -34,6 +34,7 @@ class IsAttributeNotChangedType extends IsAttributeChangedType
/**
* @param string $attribute
* @return bool
* @throws \Espo\Core\Exceptions\Error
*/
protected function check($attribute)
{

View File

@@ -33,6 +33,7 @@ class IsNewType extends \Espo\Core\Formula\Functions\Base
{
/**
* @return bool
* @throws \Espo\Core\Exceptions\Error
*/
public function process(\stdClass $item)
{

View File

@@ -47,6 +47,8 @@ class IsRelatedType extends \Espo\Core\Formula\Functions\Base implements
/**
* @return bool
* @throws \Espo\Core\Formula\Exceptions\Error
* @throws Error
*/
public function process(\stdClass $item)
{

View File

@@ -35,6 +35,8 @@ class RemoveLinkMultipleIdType extends \Espo\Core\Formula\Functions\Base
{
/**
* @return void
* @throws \Espo\Core\Formula\Exceptions\Error
* @throws Error
*/
public function process(\stdClass $item)
{

View File

@@ -45,6 +45,8 @@ class SumRelatedType extends \Espo\Core\Formula\Functions\Base implements
/**
* @return float
* @throws Error
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(stdClass $item)
{

View File

@@ -38,6 +38,8 @@ class RetrieveType extends BaseFunction
{
/**
* @return mixed
* @throws \Espo\Core\Formula\Exceptions\TooFewArguments
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(ArgumentList $args)
{

View File

@@ -35,6 +35,8 @@ class SetAttributeType extends Base
{
/**
* @return mixed
* @throws \Espo\Core\Formula\Exceptions\Error
* @throws Error
*/
public function process(\stdClass $item)
{

View File

@@ -36,6 +36,9 @@ class SplitType extends BaseFunction
{
/**
* @return string[]
* @throws \Espo\Core\Formula\Exceptions\TooFewArguments
* @throws \Espo\Core\Formula\Exceptions\BadArgumentType
* @throws \Espo\Core\Formula\Exceptions\Error
*/
public function process(ArgumentList $args)
{

View File

@@ -56,6 +56,7 @@ class Manager
* Executes a script and returns its result.
*
* @return mixed
* @throws Exceptions\Error
*/
public function run(string $script, ?Entity $entity = null, ?stdClass $variables = null)
{

View File

@@ -74,6 +74,7 @@ class Processor
* Evaluates an argument or argument list.
*
* @return mixed A result of evaluation. An array if an argument list was passed.
* @throws Error
*/
public function process(Evaluatable $item)
{
@@ -101,6 +102,7 @@ class Processor
/**
* @return mixed[]
* @throws Error
*/
private function processList(ArgumentList $args): array
{

View File

@@ -54,6 +54,10 @@ class SearchParamsFetcher
$this->textMetadataProvider = $textMetadataProvider;
}
/**
* @throws BadRequest
* @throws Forbidden
*/
public function fetch(Request $request): SearchParams
{
return SearchParams::fromRaw(
@@ -63,6 +67,8 @@ class SearchParamsFetcher
/**
* @return array<string,mixed>
* @throws BadRequest
* @throws Forbidden
*/
private function fetchRaw(Request $request): array
{
@@ -77,6 +83,7 @@ class SearchParamsFetcher
/**
* @return array<string,mixed>
* @throws BadRequest
*/
private function fetchRawJsonSearchParams(Request $request): array
{
@@ -166,6 +173,8 @@ class SearchParamsFetcher
/**
* @param array<string,mixed> $params
* @throws BadRequest
* @throws Forbidden
*/
private function handleRawParams(array &$params, Request $request): void
{
@@ -207,6 +216,7 @@ class SearchParamsFetcher
/**
* @param array<string,mixed> $params
* @throws Forbidden
*/
private function handleMaxSize(array &$params): void
{

View File

@@ -539,6 +539,7 @@ class Service implements Crud,
/**
* @param TEntity $entity
* @throws \Espo\Core\Exceptions\Conflict
*/
protected function processConcurrencyControl(Entity $entity, stdClass $data, int $versionNumber): void
{
@@ -580,6 +581,7 @@ class Service implements Crud,
/**
* @param TEntity $entity
* @throws \Espo\Core\Exceptions\Conflict
*/
protected function processDuplicateCheck(Entity $entity, stdClass $data): void
{
@@ -662,9 +664,10 @@ class Service implements Crud,
/**
* Create a record.
*
* @throws ForbiddenSilent If no create access.
*
* @return TEntity
* @throws BadRequest
* @throws Forbidden If no create access.
* @throws \Espo\Core\Exceptions\Conflict
*/
public function create(stdClass $data, CreateParams $params): Entity
{
@@ -685,7 +688,6 @@ class Service implements Crud,
}
$this->processValidation($entity, $data);
$this->processAssignmentCheck($entity);
if (!$params->skipDuplicateCheck()) {
@@ -710,11 +712,11 @@ class Service implements Crud,
/**
* Update a record.
*
* @throws BadRequest
* @throws NotFound If record not found.
* @throws Forbidden If no access.
*
* @return TEntity
* @throws NotFound If record not found.
* @throws Forbidden If no access
* @throws \Espo\Core\Exceptions\Conflict
* @throws BadRequest
*/
public function update(string $id, stdClass $data, UpdateParams $params): Entity
{
@@ -748,7 +750,6 @@ class Service implements Crud,
$entity->set($data);
$this->processValidation($entity, $data);
$this->processAssignmentCheck($entity);
$checkForDuplicates =
@@ -760,15 +761,12 @@ class Service implements Crud,
}
$this->recordHookManager->processBeforeUpdate($entity, $params);
$this->beforeUpdateEntity($entity, $data);
$this->entityManager->saveEntity($entity);
$this->afterUpdateEntity($entity, $data);
$this->prepareEntityForOutput($entity);
$this->processActionHistoryRecord('update', $entity);
return $entity;
@@ -802,13 +800,9 @@ class Service implements Crud,
}
$this->recordHookManager->processBeforeDelete($entity, $params);
$this->beforeDeleteEntity($entity);
$this->getRepository()->remove($entity);
$this->afterDeleteEntity($entity);
$this->processActionHistoryRecord('delete', $entity);
}
@@ -904,7 +898,9 @@ class Service implements Crud,
->withDeleted()
->build();
return $this->getRepository()->clone($query)->findOne();
return $this->getRepository()
->clone($query)
->findOne();
}
/**
@@ -1215,6 +1211,11 @@ class Service implements Crud,
$this->getRepository()->unrelate($entity, $link, $foreignEntity);
}
/**
* @throws Forbidden
* @throws NotFound
* @throws ForbiddenSilent
*/
public function linkFollowers(string $id, string $foreignId): void
{
if (!$this->acl->check($this->entityType, AclTable::ACTION_EDIT)) {
@@ -1280,6 +1281,11 @@ class Service implements Crud,
}
}
/**
* @throws Forbidden
* @throws NotFound
* @throws ForbiddenSilent
*/
public function unlinkFollowers(string $id, string $foreignId): void
{
if (!$this->acl->check($this->entityType, AclTable::ACTION_EDIT)) {
@@ -1330,6 +1336,11 @@ class Service implements Crud,
$this->getStreamService()->unfollowEntity($entity, $foreignId);
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function massLink(string $id, string $link, SearchParams $searchParams): bool
{
if (!$this->acl->check($this->entityType, AclTable::ACTION_EDIT)) {
@@ -1418,6 +1429,9 @@ class Service implements Crud,
return false;
}
/**
* @throws Forbidden
*/
protected function processForbiddenLinkReadCheck(string $link): void
{
$forbiddenLinkList = $this->acl
@@ -1440,6 +1454,9 @@ class Service implements Crud,
}
}
/**
* @throws Forbidden
*/
protected function processForbiddenLinkEditCheck(string $link): void
{
$forbiddenLinkList = $this->acl
@@ -1580,6 +1597,7 @@ class Service implements Crud,
/**
* Prepare an entity for output. Clears not allowed attributes.
*
* @param TEntity $entity
* @return void
*/
@@ -1632,6 +1650,12 @@ class Service implements Crud,
return $this->injectableFactory->create(EntityDuplicator::class);
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws ForbiddenSilent
* @throws NotFound
*/
public function getDuplicateAttributes(string $id): stdClass
{
if (!$id) {

View File

@@ -55,7 +55,6 @@ class ServiceContainer
/**
* @return Service<\Espo\ORM\Entity>
* @throws Error
*/
public function get(string $entityType): Service
{

View File

@@ -73,6 +73,9 @@ class SqlExecutor
$counter--;
if ($counter === 0 || !$this->isExceptionIsDeadlock($e)) {
/**
* @var PDOException $e
*/
throw $e;
}

View File

@@ -32,6 +32,7 @@ namespace Espo\ORM;
use Espo\ORM\QueryComposer\QueryComposer;
use PDO;
use PDOException;
use RuntimeException;
use Throwable;
use Closure;
@@ -83,6 +84,9 @@ class TransactionManager
catch (Throwable $e) {
$this->rollback();
/**
* @var PDOException $e
*/
throw $e;
}

View File

@@ -45,8 +45,11 @@ use Espo\Entities\UserData;
class User extends Database
{
/**
* @param \Espo\Entities\User $entity
* @param array<string,mixed> $options
* @return void
* @throws Conflict
* @throws Error
*/
protected function beforeSave(Entity $entity, array $options = [])
{
@@ -121,7 +124,7 @@ class User extends Database
->select(['id'])
->where([
'userName' => $userName,
'id!=' => $entity->id,
'id!=' => $entity->getId(),
])
->findOne();

View File

@@ -165,6 +165,10 @@ class Email extends Record implements
return SmtpParams::fromArray($smtpParams);
}
/**
* @throws BadRequest
* @throws Error
*/
public function sendEntity(EmailEntity $entity, ?User $user = null): void
{
@@ -420,6 +424,9 @@ class Email extends Record implements
}
}
/**
* @throws Error
*/
public function validateEmailAddresses(EmailEntity $entity): void
{
$from = $entity->get('from');
@@ -449,13 +456,18 @@ class Email extends Record implements
}
}
/**
* @throws BadRequest
* @throws Error
* @throws \Espo\Core\Exceptions\ForbiddenSilent
*/
public function create(stdClass $data, CreateParams $params): Entity
{
/** @var EmailEntity */
$entity = parent::create($data, $params);
if ($entity->get('status') === EmailEntity::STATUS_SENDING) {
$this->sendEntity($entity, $this->getUser());
$this->sendEntity($entity, $this->user);
}
return $entity;
@@ -472,12 +484,16 @@ class Email extends Record implements
}
}
/**
* @throws BadRequest
* @throws Error
*/
protected function afterUpdateEntity(Entity $entity, $data)
{
/** @var EmailEntity $entity */
if ($entity->get('status') === EmailEntity::STATUS_SENDING) {
$this->sendEntity($entity, $this->getUser());
$this->sendEntity($entity, $this->user);
}
$this->loadAdditionalFields($entity);
@@ -586,7 +602,7 @@ class Email extends Record implements
public function markAllAsRead(?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -619,7 +635,7 @@ class Email extends Record implements
public function markAsRead(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -640,7 +656,7 @@ class Email extends Record implements
public function markAsNotRead(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -659,7 +675,7 @@ class Email extends Record implements
public function markAsImportant(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -678,7 +694,7 @@ class Email extends Record implements
public function markAsNotImportant(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -697,7 +713,7 @@ class Email extends Record implements
public function moveToTrash(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -718,7 +734,7 @@ class Email extends Record implements
public function retrieveFromTrash(string $id, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
$update = $this->entityManager->getQueryBuilder()->update()
->in('EmailUser')
@@ -755,7 +771,7 @@ class Email extends Record implements
public function moveToFolder(string $id, ?string $folderId, ?string $userId = null): bool
{
$userId = $userId ?? $this->getUser()->getId();
$userId = $userId ?? $this->user->getId();
if ($folderId === 'inbox') {
$folderId = null;
@@ -810,6 +826,11 @@ class Email extends Record implements
return $fromAddress;
}
/**
* @throws BadRequest
* @throws Forbidden
* @throws NotFound
*/
public function getCopiedAttachments(
string $id,
?string $parentType = null,
@@ -889,6 +910,7 @@ class Email extends Record implements
/**
* @param array<string,mixed> $data
* @throws Forbidden
* @throws Error
*/
public function sendTestEmail(array $data): bool
{
@@ -904,7 +926,7 @@ class Email extends Record implements
$fromAddress = $data['fromAddress'] ?? null;
if ($userId) {
if ($userId !== $this->getUser()->getId() && !$this->getUser()->isAdmin()) {
if ($userId !== $this->user->getId() && !$this->user->isAdmin()) {
throw new Forbidden();
}
}
@@ -968,7 +990,7 @@ class Email extends Record implements
$skipFilter = false;
if ($this->getUser()->isAdmin()) {
if ($this->user->isAdmin()) {
$skipFilter = true;
}
@@ -1024,7 +1046,7 @@ class Email extends Record implements
->from('Email')
->withAccessControlFilter();
$draftsSelecBuilder = clone $selectBuilder;
$draftsSelectBuilder = clone $selectBuilder;
$selectBuilder->withWhere(
WhereItem::fromRaw([
@@ -1038,7 +1060,7 @@ class Email extends Record implements
$emailFolderList = $this->entityManager
->getRDBRepository('EmailFolder')
->where([
'assignedUserId' => $this->getUser()->getId(),
'assignedUserId' => $this->user->getId(),
])
->find();
@@ -1050,7 +1072,7 @@ class Email extends Record implements
$itemSelectBuilder = clone $selectBuilder;
if ($folderId === 'drafts') {
$itemSelectBuilder = clone $draftsSelecBuilder;
$itemSelectBuilder = clone $draftsSelectBuilder;
}
$itemSelectBuilder->withWhere(

View File

@@ -101,6 +101,8 @@ class EmailTemplate extends Record implements
/**
* @param array<string,mixed> $params
* @return array<string,mixed>
* @throws \Espo\Core\Exceptions\ForbiddenSilent
* @throws NotFound
*/
public function parse(string $id, array $params = [], bool $copyAttachments = false): array
{

View File

@@ -77,6 +77,7 @@ class Integration
/**
* @return void
* @throws Forbidden
*/
protected function processAccessCheck()
{
@@ -85,6 +86,10 @@ class Integration
}
}
/**
* @throws Forbidden
* @throws NotFound
*/
public function read(string $id): Entity
{
$this->processAccessCheck();
@@ -98,6 +103,10 @@ class Integration
return $entity;
}
/**
* @throws Forbidden
* @throws NotFound
*/
public function update(string $id, stdClass $data): Entity
{
$this->processAccessCheck();

View File

@@ -108,6 +108,8 @@ class Layout
/**
* @return array<int,mixed>|stdClass|null
* @throws NotFound
* @throws Error
*/
public function getOriginal(string $scope, string $name, ?string $setId = null)
{
@@ -145,6 +147,7 @@ class Layout
* @return mixed
* @throws Forbidden
* @throws NotFound
* @throws Error
*/
public function getForFrontend(string $scope, string $name)
{
@@ -257,6 +260,9 @@ class Layout
return $data;
}
/**
* @throws NotFound
*/
protected function getRecordFromSet(
string $scope,
string $name,
@@ -298,6 +304,8 @@ class Layout
/**
* @param mixed $data
* @return mixed
* @throws NotFound
* @throws Error
*/
public function update(string $scope, string $name, ?string $setId, $data)
{
@@ -325,7 +333,6 @@ class Layout
$layoutManager = $this->layoutManager;
$layoutManager->set($data, $scope, $name);
$layoutManager->save();
$this->dataManager->updateCacheTimestamp();
@@ -335,6 +342,8 @@ class Layout
/**
* @return array<int,mixed>|stdClass|null
* @throws NotFound
* @throws Error
*/
public function resetToDefault(string $scope, string $name, ?string $setId = null)
{
@@ -362,6 +371,10 @@ class Layout
return $this->getOriginal($scope, $name);
}
/**
* @throws Error
* @throws NotFound
*/
protected function getOriginalBottomPanelsDetail(string $scope, ?string $setId = null): stdClass
{
$relationships = $this->getOriginal($scope, 'relationships') ?? [];
@@ -398,6 +411,10 @@ class Layout
return $result;
}
/**
* @throws NotFound
* @throws Error
*/
protected function getForFrontendBottomPanelsDetail(string $scope): stdClass
{
return $this->getOriginalBottomPanelsDetail($scope);

View File

@@ -94,6 +94,7 @@ class Note extends Record
/**
* @param NoteEntity $entity
* @param stdClass $data
* @throws Forbidden
*/
protected function beforeCreateEntity(Entity $entity, $data)
{

View File

@@ -82,7 +82,7 @@ class Pdf
private $builder;
private $serviceContanier;
private $serviceContainer;
private $dataLoaderManager;
@@ -93,7 +93,7 @@ class Pdf
Language $defaultLanguage,
SelectBuilderFactory $selectBuilderFactory,
Builder $builder,
ServiceContainer $serviceContanier,
ServiceContainer $serviceContainer,
DataLoaderManager $dataLoaderManager
) {
$this->config = $config;
@@ -102,12 +102,13 @@ class Pdf
$this->defaultLanguage = $defaultLanguage;
$this->selectBuilderFactory = $selectBuilderFactory;
$this->builder = $builder;
$this->serviceContanier = $serviceContanier;
$this->serviceContainer = $serviceContainer;
$this->dataLoaderManager = $dataLoaderManager;
}
/**
* @param iterable<Entity> $entityList
* @throws Error
*/
public function generateMailMerge(
string $entityType,
@@ -127,7 +128,7 @@ class Pdf
$idDataMap = IdDataMap::create();
$service = $this->serviceContanier->get($entityType);
$service = $this->serviceContainer->get($entityType);
foreach ($entityList as $entity) {
$service->loadAdditionalFields($entity);
@@ -185,7 +186,7 @@ class Pdf
bool $checkAcl = false
): string {
$service = $this->serviceContanier->get($entityType);
$service = $this->serviceContainer->get($entityType);
$maxCount = $this->config->get('massPrintPdfMaxCount');
@@ -309,6 +310,8 @@ class Pdf
/**
* Generate PDF. ACL check is processed if `$params` is null.
*
* @throws Error
*/
public function generate(Entity $entity, Template $template, ?Params $params = null, ?Data $data = null): string
{
@@ -324,8 +327,9 @@ class Pdf
}
/**
* @deprecated
* @param ?array<string,mixed> $additionalData
* @throws Error
* @deprecated
*/
public function buildFromTemplate(
Entity $entity,
@@ -338,8 +342,10 @@ class Pdf
}
/**
* @deprecated
* @param ?array<string,mixed> $additionalData
* @throws Error
* @throws Forbidden
* @deprecated
*/
private function buildFromTemplateInternal(
Entity $entity,
@@ -352,7 +358,7 @@ class Pdf
$entityType = $entity->getEntityType();
$service = $this->serviceContanier->get($entityType);
$service = $this->serviceContainer->get($entityType);
$service->loadAdditionalFields($entity);

View File

@@ -260,9 +260,10 @@ class Record extends RecordService implements
}
/**
* @deprecated
* @param array<string,mixed> $params
* @param Collection<TEntity> $collection
* @throws ForbiddenSilent
* @deprecated
*/
public function exportCollection(array $params, Collection $collection): string
{

View File

@@ -38,7 +38,6 @@ use Espo\ORM\BaseEntity;
use Espo\Entities\User;
use Espo\Core\{
Exceptions\Error,
Utils\Json,
Select\SelectBuilderFactory,
Acl,
@@ -58,6 +57,7 @@ use Espo\{
};
use RuntimeException;
use LogicException;
class Export
{
@@ -138,7 +138,7 @@ class Export
public function run(): Result
{
if (!$this->params) {
throw new Error("No params set.");
throw new LogicException("No params set.");
}
$params = $this->params;