ref
This commit is contained in:
@@ -148,7 +148,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($note->getParentType(), $note->getParentId());
|
$parent = $this->entityManager->getEntityById($note->getParentType(), $note->getParentId());
|
||||||
|
|
||||||
if ($parent && $this->aclManager->checkEntity($user, $parent)) {
|
if ($parent && $this->aclManager->checkEntity($user, $parent)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($parentType, $parentId);
|
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||||
|
|
||||||
if ($parent && $this->aclManager->checkEntityStream($user, $parent)) {
|
if ($parent && $this->aclManager->checkEntityStream($user, $parent)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -154,7 +154,7 @@ class AccessChecker implements AccessEntityCREDChecker
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($note->getParentType(), $note->getParentId());
|
$parent = $this->entityManager->getEntityById($note->getParentType(), $note->getParentId());
|
||||||
|
|
||||||
if ($parent && $this->aclManager->checkEntity($user, $parent)) {
|
if ($parent && $this->aclManager->checkEntity($user, $parent)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ class Wysiwyg implements FieldDuplicator
|
|||||||
|
|
||||||
foreach ($attachmentIdList as $id) {
|
foreach ($attachmentIdList as $id) {
|
||||||
/** @var Attachment|null $attachment */
|
/** @var Attachment|null $attachment */
|
||||||
$attachment = $this->entityManager->getEntity(Attachment::ENTITY_TYPE, $id);
|
$attachment = $this->entityManager->getEntityById(Attachment::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if (!$attachment) {
|
if (!$attachment) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -188,7 +188,7 @@ class IcsDataLoader implements Loader
|
|||||||
}
|
}
|
||||||
|
|
||||||
$createdEvent = $this->entityManager
|
$createdEvent = $this->entityManager
|
||||||
->getEntity($emailSameEvent->get('createdEventType'), $emailSameEvent->get('createdEventId'));
|
->getEntityById($emailSameEvent->get('createdEventType'), $emailSameEvent->get('createdEventId'));
|
||||||
|
|
||||||
if (!$createdEvent) {
|
if (!$createdEvent) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ class Merger
|
|||||||
$entityType = $params->getEntityType();
|
$entityType = $params->getEntityType();
|
||||||
$id = $params->getId();
|
$id = $params->getId();
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($entityType, $id);
|
$entity = $this->entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new NotFound("Record not found.");
|
throw new NotFound("Record not found.");
|
||||||
@@ -167,7 +167,7 @@ class Merger
|
|||||||
$list = [];
|
$list = [];
|
||||||
|
|
||||||
foreach ($sourceIdList as $sourceId) {
|
foreach ($sourceIdList as $sourceId) {
|
||||||
$sourceEntity = $this->entityManager->getEntity($entityType, $sourceId);
|
$sourceEntity = $this->entityManager->getEntityById($entityType, $sourceId);
|
||||||
|
|
||||||
if (!$sourceEntity) {
|
if (!$sourceEntity) {
|
||||||
throw new NotFound("Source record not found.");
|
throw new NotFound("Source record not found.");
|
||||||
|
|||||||
@@ -83,7 +83,7 @@ class GenerateType extends BaseFunction implements
|
|||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$entity = $em->getEntity($entityType, $id);
|
$entity = $em->getEntityById($entityType, $id);
|
||||||
} catch (Exception $e) {
|
} catch (Exception $e) {
|
||||||
$this->log("Message: " . $e->getMessage() . ".");
|
$this->log("Message: " . $e->getMessage() . ".");
|
||||||
|
|
||||||
@@ -106,7 +106,7 @@ class GenerateType extends BaseFunction implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($fileName) {
|
if ($fileName) {
|
||||||
if (substr($fileName, -4) !== '.pdf') {
|
if (!str_ends_with($fileName, '.pdf')) {
|
||||||
$fileName .= '.pdf';
|
$fileName .= '.pdf';
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class SendType extends BaseFunction implements
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var Sms|null $sms */
|
/** @var Sms|null $sms */
|
||||||
$sms = $this->entityManager->getEntity(Sms::ENTITY_TYPE, $id);
|
$sms = $this->entityManager->getEntityById(Sms::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if (!$sms) {
|
if (!$sms) {
|
||||||
$this->log("Sms '{$id}' does not exist.");
|
$this->log("Sms '{$id}' does not exist.");
|
||||||
|
|||||||
@@ -62,10 +62,10 @@ class SendAccessInfoType extends BaseFunction implements
|
|||||||
$this->throwBadArgumentType(1, 'string');
|
$this->throwBadArgumentType(1, 'string');
|
||||||
}
|
}
|
||||||
|
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
$this->log("User '{$userId}' does not exist.");
|
$this->log("User '$userId' does not exist.");
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,6 +38,9 @@ class AttributeType extends \Espo\Core\Formula\Functions\AttributeType implement
|
|||||||
{
|
{
|
||||||
use Di\EntityManagerSetter;
|
use Di\EntityManagerSetter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Error
|
||||||
|
*/
|
||||||
public function process(\stdClass $item)
|
public function process(\stdClass $item)
|
||||||
{
|
{
|
||||||
if (count($item->value) < 3) {
|
if (count($item->value) < 3) {
|
||||||
@@ -60,7 +63,7 @@ class AttributeType extends \Espo\Core\Formula\Functions\AttributeType implement
|
|||||||
throw new Error("Formula record\\attribute: Empty attribute.");
|
throw new Error("Formula record\\attribute: Empty attribute.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($entityType, $id);
|
$entity = $this->entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -29,6 +29,12 @@
|
|||||||
|
|
||||||
namespace Espo\Core\Formula\Functions\RecordGroup;
|
namespace Espo\Core\Formula\Functions\RecordGroup;
|
||||||
|
|
||||||
|
use Espo\Core\Exceptions\BadRequest;
|
||||||
|
use Espo\Core\Exceptions\Forbidden;
|
||||||
|
use Espo\Core\Formula\Exceptions\BadArgumentType;
|
||||||
|
use Espo\Core\Formula\Exceptions\Error;
|
||||||
|
use Espo\Core\Formula\Exceptions\ExecutionException;
|
||||||
|
use Espo\Core\Formula\Exceptions\TooFewArguments;
|
||||||
use Espo\Core\ORM\Entity as CoreEntity;
|
use Espo\Core\ORM\Entity as CoreEntity;
|
||||||
use Espo\Core\Formula\ArgumentList;
|
use Espo\Core\Formula\ArgumentList;
|
||||||
use Espo\Core\Formula\Functions\BaseFunction;
|
use Espo\Core\Formula\Functions\BaseFunction;
|
||||||
@@ -46,6 +52,14 @@ class FindRelatedManyType extends BaseFunction implements
|
|||||||
use Di\MetadataSetter;
|
use Di\MetadataSetter;
|
||||||
use Di\InjectableFactorySetter;
|
use Di\InjectableFactorySetter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Error
|
||||||
|
* @throws BadRequest
|
||||||
|
* @throws TooFewArguments
|
||||||
|
* @throws BadArgumentType
|
||||||
|
* @throws Forbidden
|
||||||
|
* @throws ExecutionException
|
||||||
|
*/
|
||||||
public function process(ArgumentList $args)
|
public function process(ArgumentList $args)
|
||||||
{
|
{
|
||||||
$args = $this->evaluate($args);
|
$args = $this->evaluate($args);
|
||||||
@@ -94,7 +108,7 @@ class FindRelatedManyType extends BaseFunction implements
|
|||||||
$this->throwBadArgumentType(4, 'string');
|
$this->throwBadArgumentType(4, 'string');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $entityManager->getEntity($entityType, $id);
|
$entity = $entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
$this->log("record\\findRelatedMany: Entity $entityType $id not found.", 'notice');
|
$this->log("record\\findRelatedMany: Entity $entityType $id not found.", 'notice');
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ class FindRelatedOneType extends BaseFunction implements
|
|||||||
$this->throwBadArgumentType(3, 'string');
|
$this->throwBadArgumentType(3, 'string');
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $entityManager->getEntity($entityType, $id);
|
$entity = $entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -78,10 +78,10 @@ class RelationColumnType extends BaseFunction implements
|
|||||||
$em = $this->entityManager;
|
$em = $this->entityManager;
|
||||||
|
|
||||||
if (!$em->hasRepository($entityType)) {
|
if (!$em->hasRepository($entityType)) {
|
||||||
$this->throwError("Repository '{$entityType}' does not exist.");
|
$this->throwError("Repository '$entityType' does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $em->getEntity($entityType, $id);
|
$entity = $em->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ class UpdateRelationColumnType extends BaseFunction implements
|
|||||||
$this->throwError("Repository does not exist.");
|
$this->throwError("Repository does not exist.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $em->getEntity($entityType, $id);
|
$entity = $em->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -81,7 +81,7 @@ class ScheduleUtil
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var ScheduledJobEntity|null $scheduledJob */
|
/** @var ScheduledJobEntity|null $scheduledJob */
|
||||||
$scheduledJob = $this->entityManager->getEntity(ScheduledJobEntity::ENTITY_TYPE, $scheduledJobId);
|
$scheduledJob = $this->entityManager->getEntityById(ScheduledJobEntity::ENTITY_TYPE, $scheduledJobId);
|
||||||
|
|
||||||
if (!$scheduledJob) {
|
if (!$scheduledJob) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -51,6 +51,6 @@ class Preferences implements Loader
|
|||||||
$this->systemUser->getId();
|
$this->systemUser->getId();
|
||||||
|
|
||||||
/** @var PreferencesEntity */
|
/** @var PreferencesEntity */
|
||||||
return $this->entityManager->getEntity(PreferencesEntity::ENTITY_TYPE, $id);
|
return $this->entityManager->getEntityById(PreferencesEntity::ENTITY_TYPE, $id);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ class AfterFetch implements AfterFetchInterface
|
|||||||
$emailToProcess = $email;
|
$emailToProcess = $email;
|
||||||
|
|
||||||
if ($email->isFetched()) {
|
if ($email->isFetched()) {
|
||||||
$emailToProcess = $this->entityManager->getEntity(Email::ENTITY_TYPE, $email->getId());
|
$emailToProcess = $this->entityManager->getEntityById(Email::ENTITY_TYPE, $email->getId());
|
||||||
} else {
|
} else {
|
||||||
$emailToProcess->updateFetchedValues();
|
$emailToProcess->updateFetchedValues();
|
||||||
}
|
}
|
||||||
@@ -122,7 +122,7 @@ class AfterFetch implements AfterFetchInterface
|
|||||||
$user = null;
|
$user = null;
|
||||||
|
|
||||||
if ($account->getAssignedUser()) {
|
if ($account->getAssignedUser()) {
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $account->getAssignedUser()->getId());
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $account->getAssignedUser()->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->autoReply($account, $email, null, $user);
|
$this->autoReply($account, $email, null, $user);
|
||||||
@@ -137,7 +137,7 @@ class AfterFetch implements AfterFetchInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($parentLink->getEntityType(), $parentLink->getId());
|
$parent = $this->entityManager->getEntityById($parentLink->getEntityType(), $parentLink->getId());
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
return;
|
return;
|
||||||
@@ -438,7 +438,7 @@ class AfterFetch implements AfterFetchInterface
|
|||||||
private function emailToCase(Email $email, array $params): CaseObj
|
private function emailToCase(Email $email, array $params): CaseObj
|
||||||
{
|
{
|
||||||
/** @var CaseObj $case */
|
/** @var CaseObj $case */
|
||||||
$case = $this->entityManager->getEntity(CaseObj::ENTITY_TYPE);
|
$case = $this->entityManager->getNewEntity(CaseObj::ENTITY_TYPE);
|
||||||
|
|
||||||
$case->populateDefaults();
|
$case->populateDefaults();
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ class AfterFetch implements AfterFetchInterface
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($parentLink->getEntityType(), $parentLink->getId());
|
$parent = $this->entityManager->getEntityById($parentLink->getEntityType(), $parentLink->getId());
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -50,6 +50,9 @@ class Process implements Job
|
|||||||
private Language $language
|
private Language $language
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Error
|
||||||
|
*/
|
||||||
public function run(JobData $data): void
|
public function run(JobData $data): void
|
||||||
{
|
{
|
||||||
$id = $data->getTargetId();
|
$id = $data->getTargetId();
|
||||||
@@ -59,17 +62,17 @@ class Process implements Job
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var MassActionEntity|null $entity */
|
/** @var MassActionEntity|null $entity */
|
||||||
$entity = $this->entityManager->getEntity(MassActionEntity::ENTITY_TYPE, $id);
|
$entity = $this->entityManager->getEntityById(MassActionEntity::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if ($entity === null) {
|
if ($entity === null) {
|
||||||
throw new Error("MassAction '{$id}' not found.");
|
throw new Error("MassAction '$id' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $entity->getCreatedBy()->getId());
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $entity->getCreatedBy()->getId());
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new Error("MassAction '{$id}', user not found.");
|
throw new Error("MassAction '$id', user not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
$params = $entity->getParams();
|
$params = $entity->getParams();
|
||||||
|
|||||||
@@ -68,6 +68,7 @@ class EntityManagerProxy
|
|||||||
*/
|
*/
|
||||||
public function getEntity(string $entityType, ?string $id = null): ?Entity
|
public function getEntity(string $entityType, ?string $id = null): ?Entity
|
||||||
{
|
{
|
||||||
|
/** @noinspection PhpDeprecationInspection */
|
||||||
return $this->getEntityManager()->getEntity($entityType, $id);
|
return $this->getEntityManager()->getEntity($entityType, $id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,11 @@ use Espo\Core\Portal\Utils\Config;
|
|||||||
|
|
||||||
class Application extends BaseApplication
|
class Application extends BaseApplication
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws Forbidden
|
||||||
|
* @throws Error
|
||||||
|
* @throws NotFound
|
||||||
|
*/
|
||||||
public function __construct(?string $portalId)
|
public function __construct(?string $portalId)
|
||||||
{
|
{
|
||||||
date_default_timezone_set('UTC');
|
date_default_timezone_set('UTC');
|
||||||
@@ -56,12 +61,13 @@ class Application extends BaseApplication
|
|||||||
|
|
||||||
public function getContainer(): Container
|
public function getContainer(): Container
|
||||||
{
|
{
|
||||||
$container = parent::getContainer();
|
|
||||||
|
|
||||||
/** @var Container */
|
/** @var Container */
|
||||||
return $container;
|
return parent::getContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Error
|
||||||
|
*/
|
||||||
protected function initContainer(): void
|
protected function initContainer(): void
|
||||||
{
|
{
|
||||||
$container = (new ContainerBuilder())
|
$container = (new ContainerBuilder())
|
||||||
@@ -77,6 +83,11 @@ class Application extends BaseApplication
|
|||||||
$this->container = $container;
|
$this->container = $container;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Forbidden
|
||||||
|
* @throws Error
|
||||||
|
* @throws NotFound
|
||||||
|
*/
|
||||||
protected function initPortal(?string $portalId): void
|
protected function initPortal(?string $portalId): void
|
||||||
{
|
{
|
||||||
if (!$portalId) {
|
if (!$portalId) {
|
||||||
@@ -85,7 +96,7 @@ class Application extends BaseApplication
|
|||||||
|
|
||||||
$entityManager = $this->container->getByClass(EntityManager::class);
|
$entityManager = $this->container->getByClass(EntityManager::class);
|
||||||
|
|
||||||
$portal = $entityManager->getEntity(Portal::ENTITY_TYPE, $portalId);
|
$portal = $entityManager->getEntityById(Portal::ENTITY_TYPE, $portalId);
|
||||||
|
|
||||||
if (!$portal) {
|
if (!$portal) {
|
||||||
$portal = $entityManager
|
$portal = $entityManager
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ class UserTimeZoneProvider
|
|||||||
|
|
||||||
public function get(): string
|
public function get(): string
|
||||||
{
|
{
|
||||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $this->user->getId());
|
$preferences = $this->entityManager->getEntityById(Preferences::ENTITY_TYPE, $this->user->getId());
|
||||||
|
|
||||||
if (!$preferences) {
|
if (!$preferences) {
|
||||||
return 'UTC';
|
return 'UTC';
|
||||||
|
|||||||
@@ -276,7 +276,7 @@ class SelectManager
|
|||||||
protected function getSeed(): Entity
|
protected function getSeed(): Entity
|
||||||
{
|
{
|
||||||
if (empty($this->seed)) {
|
if (empty($this->seed)) {
|
||||||
$this->seed = $this->entityManager->getEntity($this->entityType);
|
$this->seed = $this->entityManager->getNewEntity($this->entityType);
|
||||||
}
|
}
|
||||||
return $this->seed;
|
return $this->seed;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ class DateTimeFactory
|
|||||||
|
|
||||||
public function createWithUserTimeZone(User $user): DateTime
|
public function createWithUserTimeZone(User $user): DateTime
|
||||||
{
|
{
|
||||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $user->getId());
|
$preferences = $this->entityManager->getEntityById(Preferences::ENTITY_TYPE, $user->getId());
|
||||||
|
|
||||||
$timeZone = $this->config->get('timeZone') ?? 'UTC';
|
$timeZone = $this->config->get('timeZone') ?? 'UTC';
|
||||||
|
|
||||||
|
|||||||
@@ -71,6 +71,11 @@ class Notification extends Entity
|
|||||||
return $this->get('data');
|
return $this->get('data');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getUserId(): ?string
|
||||||
|
{
|
||||||
|
return $this->get('userId');
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param stdClass|array<string, mixed> $data
|
* @param stdClass|array<string, mixed> $data
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -102,6 +102,6 @@ class RoundRobin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return $this->entityManager->getEntity(User::ENTITY_TYPE, $userIdList[$num]);
|
return $this->entityManager->getRDBRepositoryByClass(User::class)->getById($userIdList[$num]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$campaign = $this->entityManager->getEntity('Campaign', $campaignId);
|
$campaign = $this->entityManager->getEntityById('Campaign', $campaignId);
|
||||||
|
|
||||||
if ($campaign && $this->aclManager->checkOwnershipOwn($user, $campaign)) {
|
if ($campaign && $this->aclManager->checkOwnershipOwn($user, $campaign)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -71,7 +71,7 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$campaign = $this->entityManager->getEntity('Campaign', $campaignId);
|
$campaign = $this->entityManager->getEntityById('Campaign', $campaignId);
|
||||||
|
|
||||||
if ($campaign && $this->aclManager->checkOwnershipTeam($user, $campaign)) {
|
if ($campaign && $this->aclManager->checkOwnershipTeam($user, $campaign)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$campaign = $this->entityManager->getEntity('Campaign', $campaignId);
|
$campaign = $this->entityManager->getEntityById('Campaign', $campaignId);
|
||||||
|
|
||||||
if ($campaign && $this->aclManager->checkOwnershipOwn($user, $campaign)) {
|
if ($campaign && $this->aclManager->checkOwnershipOwn($user, $campaign)) {
|
||||||
return true;
|
return true;
|
||||||
@@ -71,7 +71,7 @@ class OwnershipChecker implements OwnershipOwnChecker, OwnershipTeamChecker
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$campaign = $this->entityManager->getEntity('Campaign', $campaignId);
|
$campaign = $this->entityManager->getEntityById('Campaign', $campaignId);
|
||||||
|
|
||||||
if ($campaign && $this->aclManager->checkOwnershipTeam($user, $campaign)) {
|
if ($campaign && $this->aclManager->checkOwnershipTeam($user, $campaign)) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ class AfterCreate implements SaveHook
|
|||||||
array $excludingActionList
|
array $excludingActionList
|
||||||
): void {
|
): void {
|
||||||
|
|
||||||
$campaign = $this->entityManager->getEntity(Campaign::ENTITY_TYPE, $sourceCampaignId);
|
$campaign = $this->entityManager->getEntityById(Campaign::ENTITY_TYPE, $sourceCampaignId);
|
||||||
|
|
||||||
if (!$campaign) {
|
if (!$campaign) {
|
||||||
throw new NotFound("Campaign not found.");
|
throw new NotFound("Campaign not found.");
|
||||||
|
|||||||
@@ -248,7 +248,7 @@ class Service
|
|||||||
protected function getActivitiesUserEmailQuery(User $entity, array $statusList = [])
|
protected function getActivitiesUserEmailQuery(User $entity, array $statusList = [])
|
||||||
{
|
{
|
||||||
if ($entity->isPortal() && $entity->get('contactId')) {
|
if ($entity->isPortal() && $entity->get('contactId')) {
|
||||||
$contact = $this->entityManager->getEntity(Contact::ENTITY_TYPE, $entity->get('contactId'));
|
$contact = $this->entityManager->getEntityById(Contact::ENTITY_TYPE, $entity->get('contactId'));
|
||||||
|
|
||||||
if ($contact) {
|
if ($contact) {
|
||||||
return $this->getActivitiesEmailQuery($contact, $statusList);
|
return $this->getActivitiesEmailQuery($contact, $statusList);
|
||||||
@@ -767,7 +767,7 @@ class Service
|
|||||||
throw new Forbidden();
|
throw new Forbidden();
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($scope, $id);
|
$entity = $this->entityManager->getEntityById($scope, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
|
|||||||
@@ -155,7 +155,7 @@ class Service
|
|||||||
}
|
}
|
||||||
|
|
||||||
foreach ($ids as $id) {
|
foreach ($ids as $id) {
|
||||||
$entity = $this->entityManager->getEntity($entityType, $id);
|
$entity = $this->entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if ($entity && $this->acl->checkEntityEdit($entity)) {
|
if ($entity && $this->acl->checkEntityEdit($entity)) {
|
||||||
$entity->set('status', Meeting::STATUS_HELD);
|
$entity->set('status', Meeting::STATUS_HELD);
|
||||||
|
|||||||
@@ -442,7 +442,7 @@ class RDBRelation
|
|||||||
$typeAttribute = $this->relationName . 'Type';
|
$typeAttribute = $this->relationName . 'Type';
|
||||||
|
|
||||||
if (!$fromEntity->has($idAttribute) || !$fromEntity->has($typeAttribute)) {
|
if (!$fromEntity->has($idAttribute) || !$fromEntity->has($typeAttribute)) {
|
||||||
$fromEntity = $this->entityManager->getEntity($fromEntity->getEntityType(), $fromEntity->getId());
|
$fromEntity = $this->entityManager->getEntityById($fromEntity->getEntityType(), $fromEntity->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$fromEntity) {
|
if (!$fromEntity) {
|
||||||
@@ -461,7 +461,7 @@ class RDBRelation
|
|||||||
$idAttribute = $this->relationName . 'Id';
|
$idAttribute = $this->relationName . 'Id';
|
||||||
|
|
||||||
if (!$fromEntity->has($idAttribute)) {
|
if (!$fromEntity->has($idAttribute)) {
|
||||||
$fromEntity = $this->entityManager->getEntity($fromEntity->getEntityType(), $fromEntity->getId());
|
$fromEntity = $this->entityManager->getEntityById($fromEntity->getEntityType(), $fromEntity->getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$fromEntity) {
|
if (!$fromEntity) {
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ class EmailAddress extends Database implements
|
|||||||
->where(['id' => $itemEntityId])
|
->where(['id' => $itemEntityId])
|
||||||
->findOne();
|
->findOne();
|
||||||
} else {
|
} else {
|
||||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
$entity = $this->entityManager->getEntityById($itemEntityType, $itemEntityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
@@ -295,7 +295,7 @@ class EmailAddress extends Database implements
|
|||||||
->where(['id' => $itemEntityId])
|
->where(['id' => $itemEntityId])
|
||||||
->findOne();
|
->findOne();
|
||||||
} else {
|
} else {
|
||||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
$entity = $this->entityManager->getEntityById($itemEntityType, $itemEntityId);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($entity) {
|
if ($entity) {
|
||||||
@@ -354,7 +354,7 @@ class EmailAddress extends Database implements
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
$entity = $this->entityManager->getEntityById($itemEntityType, $itemEntityId);
|
||||||
|
|
||||||
if ($entity) {
|
if ($entity) {
|
||||||
if ($entity instanceof UserEntity) {
|
if ($entity instanceof UserEntity) {
|
||||||
|
|||||||
@@ -191,7 +191,7 @@ class PhoneNumber extends Database implements
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
$entity = $this->entityManager->getEntityById($itemEntityType, $itemEntityId);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
continue;
|
continue;
|
||||||
@@ -244,7 +244,7 @@ class PhoneNumber extends Database implements
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($itemEntityType, $itemEntityId);
|
$entity = $this->entityManager->getEntityById($itemEntityType, $itemEntityId);
|
||||||
|
|
||||||
if ($entity) {
|
if ($entity) {
|
||||||
if ($entity instanceof UserEntity) {
|
if ($entity instanceof UserEntity) {
|
||||||
|
|||||||
@@ -273,7 +273,7 @@ class Preferences implements Repository,
|
|||||||
$this->entityManager->getQueryExecutor()->execute($insert);
|
$this->entityManager->getQueryExecutor()->execute($insert);
|
||||||
|
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $entity->getId());
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $entity->getId());
|
||||||
|
|
||||||
if ($user && !$user->isPortal()) {
|
if ($user && !$user->isPortal()) {
|
||||||
$this->storeAutoFollowEntityTypeList($entity);
|
$this->storeAutoFollowEntityTypeList($entity);
|
||||||
|
|||||||
@@ -213,7 +213,7 @@ class RecordTree extends Record
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
$category = $this->entityManager->getEntity($this->entityType, $id);
|
$category = $this->entityManager->getEntityById($this->entityType, $id);
|
||||||
|
|
||||||
if (!$category) {
|
if (!$category) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ class Erasor implements
|
|||||||
|
|
||||||
$service = $this->recordServiceContainer->get($entityType);
|
$service = $this->recordServiceContainer->get($entityType);
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($entityType, $id);
|
$entity = $this->entityManager->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
|
|||||||
@@ -41,7 +41,6 @@ use Espo\Entities\Notification;
|
|||||||
use Espo\Entities\Portal;
|
use Espo\Entities\Portal;
|
||||||
use Espo\Entities\Preferences;
|
use Espo\Entities\Preferences;
|
||||||
use Espo\Entities\User;
|
use Espo\Entities\User;
|
||||||
use Espo\ORM\Entity;
|
|
||||||
use Espo\ORM\EntityManager;
|
use Espo\ORM\EntityManager;
|
||||||
use Espo\ORM\Query\SelectBuilder as SelectBuilder;
|
use Espo\ORM\Query\SelectBuilder as SelectBuilder;
|
||||||
use Espo\Core\Htmlizer\Htmlizer;
|
use Espo\Core\Htmlizer\Htmlizer;
|
||||||
@@ -163,12 +162,12 @@ class Processor
|
|||||||
->getQueryComposer()
|
->getQueryComposer()
|
||||||
->compose($unionQuery);
|
->compose($unionQuery);
|
||||||
|
|
||||||
/** @var Collection<Notification> $notificationList */
|
/** @var Collection<Notification> $notifications */
|
||||||
$notificationList = $this->entityManager
|
$notifications = $this->entityManager
|
||||||
->getRDBRepository(Notification::ENTITY_TYPE)
|
->getRDBRepository(Notification::ENTITY_TYPE)
|
||||||
->findBySql($sql);
|
->findBySql($sql);
|
||||||
|
|
||||||
foreach ($notificationList as $notification) {
|
foreach ($notifications as $notification) {
|
||||||
$notification->set('emailIsProcessed', true);
|
$notification->set('emailIsProcessed', true);
|
||||||
|
|
||||||
$type = $notification->getType();
|
$type = $notification->getType();
|
||||||
@@ -255,7 +254,7 @@ class Processor
|
|||||||
return $builder;
|
return $builder;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processNotificationMentionInPost(Entity $notification): void
|
protected function processNotificationMentionInPost(Notification $notification): void
|
||||||
{
|
{
|
||||||
if (!$notification->get('userId')) {
|
if (!$notification->get('userId')) {
|
||||||
return;
|
return;
|
||||||
@@ -264,7 +263,7 @@ class Processor
|
|||||||
$userId = $notification->get('userId');
|
$userId = $notification->get('userId');
|
||||||
|
|
||||||
/** @var ?User $user */
|
/** @var ?User $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return;
|
return;
|
||||||
@@ -276,7 +275,7 @@ class Processor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $userId);
|
$preferences = $this->entityManager->getEntityById(Preferences::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$preferences) {
|
if (!$preferences) {
|
||||||
return;
|
return;
|
||||||
@@ -286,12 +285,12 @@ class Processor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($notification->get('relatedType') !== Note::ENTITY_TYPE || !$notification->get('relatedId')) {
|
if (!$notification->getRelated() || $notification->getRelated()->getEntityType() !== Note::ENTITY_TYPE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ?Note $note */
|
/** @var ?Note $note */
|
||||||
$note = $this->entityManager->getEntity(Note::ENTITY_TYPE, $notification->get('relatedId'));
|
$note = $this->entityManager->getEntityById(Note::ENTITY_TYPE, $notification->getRelated()->getId());
|
||||||
|
|
||||||
if (!$note) {
|
if (!$note) {
|
||||||
return;
|
return;
|
||||||
@@ -299,19 +298,19 @@ class Processor
|
|||||||
|
|
||||||
$parent = null;
|
$parent = null;
|
||||||
|
|
||||||
$parentId = $note->get('parentId');
|
$parentId = $note->getParentId();
|
||||||
$parentType = $note->get('parentType');
|
$parentType = $note->getParentType();
|
||||||
|
|
||||||
$data = [];
|
$data = [];
|
||||||
|
|
||||||
if ($parentId && $parentType) {
|
if ($parentId && $parentType) {
|
||||||
$parent = $this->entityManager->getEntity($parentType, $parentId);
|
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data['url'] = $this->getSiteUrl($user) . '/#' . $parentType . '/view/' . $parentId;
|
$data['url'] = "{$this->getSiteUrl($user)}/#$parentType/view/$parentId";
|
||||||
$data['parentName'] = $parent->get('name');
|
$data['parentName'] = $parent->get('name');
|
||||||
$data['parentType'] = $parentType;
|
$data['parentType'] = $parentType;
|
||||||
$data['parentId'] = $parentId;
|
$data['parentId'] = $parentId;
|
||||||
@@ -345,15 +344,13 @@ class Processor
|
|||||||
->addToAddress($emailAddress);
|
->addToAddress($emailAddress);
|
||||||
$email->set('isSystem', true);
|
$email->set('isSystem', true);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if ($parentId && $parentType) {
|
if ($parentId && $parentType) {
|
||||||
$email->setParent(LinkParent::create($parentType, $parentId));
|
$email->setParent(LinkParent::create($parentType, $parentId));
|
||||||
}
|
}
|
||||||
|
|
||||||
$senderParams = SenderParams::create();
|
$senderParams = SenderParams::create();
|
||||||
|
|
||||||
if ($parent) {
|
if ($parent && $parentType) {
|
||||||
$handler = $this->getHandler('mention', $parentType);
|
$handler = $this->getHandler('mention', $parentType);
|
||||||
|
|
||||||
if ($handler) {
|
if ($handler) {
|
||||||
@@ -372,18 +369,18 @@ class Processor
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function processNotificationNote(Entity $notification): void
|
protected function processNotificationNote(Notification $notification): void
|
||||||
{
|
{
|
||||||
if ($notification->get('relatedType') !== Note::ENTITY_TYPE) {
|
if (!$notification->getRelated()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notification->get('relatedId')) {
|
if ($notification->getRelated()->getEntityType() !== Note::ENTITY_TYPE) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var ?Note $note */
|
/** @var ?Note $note */
|
||||||
$note = $this->entityManager->getEntity(Note::ENTITY_TYPE, $notification->get('relatedId'));
|
$note = $this->entityManager->getEntityById(Note::ENTITY_TYPE, $notification->getRelated()->getId());
|
||||||
|
|
||||||
if (!$note) {
|
if (!$note) {
|
||||||
return;
|
return;
|
||||||
@@ -391,30 +388,30 @@ class Processor
|
|||||||
|
|
||||||
$noteNotificationTypeList = $this->config->get('streamEmailNotificationsTypeList', []);
|
$noteNotificationTypeList = $this->config->get('streamEmailNotificationsTypeList', []);
|
||||||
|
|
||||||
if (!in_array($note->get('type'), $noteNotificationTypeList)) {
|
if (!in_array($note->getType(), $noteNotificationTypeList)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!$notification->get('userId')) {
|
if (!$notification->getUserId()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$userId = $notification->get('userId');
|
$userId = $notification->getUserId();
|
||||||
|
|
||||||
/** @var ?User $user */
|
/** @var ?User $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$emailAddress = $user->get('emailAddress');
|
$emailAddress = $user->getEmailAddress();
|
||||||
|
|
||||||
if (!$emailAddress) {
|
if (!$emailAddress) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$preferences = $this->entityManager->getEntity(Preferences::ENTITY_TYPE, $userId);
|
$preferences = $this->entityManager->getEntityById(Preferences::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$preferences) {
|
if (!$preferences) {
|
||||||
return;
|
return;
|
||||||
@@ -643,7 +640,7 @@ class Processor
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$parent = $this->entityManager->getEntity($parentType, $parentId);
|
$parent = $this->entityManager->getEntityById($parentType, $parentId);
|
||||||
|
|
||||||
if (!$parent) {
|
if (!$parent) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -108,7 +108,7 @@ class Processor
|
|||||||
$data->getParentId() &&
|
$data->getParentId() &&
|
||||||
$data->getParentType()
|
$data->getParentType()
|
||||||
) {
|
) {
|
||||||
$parent = $this->entityManager->getEntity($data->getParentType(), $data->getParentId());
|
$parent = $this->entityManager->getEntityById($data->getParentType(), $data->getParentId());
|
||||||
|
|
||||||
if ($parent) {
|
if ($parent) {
|
||||||
$service = $this->recordServiceContainer->get($data->getParentType());
|
$service = $this->recordServiceContainer->get($data->getParentType());
|
||||||
@@ -141,7 +141,7 @@ class Processor
|
|||||||
}
|
}
|
||||||
|
|
||||||
if ($data->getRelatedId() && $data->getRelatedType()) {
|
if ($data->getRelatedId() && $data->getRelatedType()) {
|
||||||
$related = $this->entityManager->getEntity($data->getRelatedType(), $data->getRelatedId());
|
$related = $this->entityManager->getEntityById($data->getRelatedType(), $data->getRelatedId());
|
||||||
|
|
||||||
if (
|
if (
|
||||||
$related &&
|
$related &&
|
||||||
|
|||||||
@@ -40,7 +40,6 @@ use Espo\Tools\Export\Result;
|
|||||||
use Espo\Core\Utils\Language;
|
use Espo\Core\Utils\Language;
|
||||||
|
|
||||||
use Espo\ORM\EntityManager;
|
use Espo\ORM\EntityManager;
|
||||||
|
|
||||||
use Espo\Entities\Export as ExportEntity;
|
use Espo\Entities\Export as ExportEntity;
|
||||||
use Espo\Entities\Notification;
|
use Espo\Entities\Notification;
|
||||||
use Espo\Entities\User;
|
use Espo\Entities\User;
|
||||||
@@ -49,22 +48,15 @@ use Throwable;
|
|||||||
|
|
||||||
class Process implements Job
|
class Process implements Job
|
||||||
{
|
{
|
||||||
private EntityManager $entityManager;
|
|
||||||
|
|
||||||
private Factory $factory;
|
|
||||||
|
|
||||||
private Language $language;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
EntityManager $entityManager,
|
private EntityManager $entityManager,
|
||||||
Factory $factory,
|
private Factory $factory,
|
||||||
Language $language
|
private Language $language
|
||||||
) {
|
) {}
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->factory = $factory;
|
|
||||||
$this->language = $language;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws Error
|
||||||
|
*/
|
||||||
public function run(JobData $data): void
|
public function run(JobData $data): void
|
||||||
{
|
{
|
||||||
$id = $data->getTargetId();
|
$id = $data->getTargetId();
|
||||||
@@ -74,17 +66,17 @@ class Process implements Job
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var ExportEntity|null $entity */
|
/** @var ExportEntity|null $entity */
|
||||||
$entity = $this->entityManager->getEntity(ExportEntity::ENTITY_TYPE, $id);
|
$entity = $this->entityManager->getEntityById(ExportEntity::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if ($entity === null) {
|
if ($entity === null) {
|
||||||
throw new Error("Export '{$id}' not found.");
|
throw new Error("Export '$id' not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @var User|null $user */
|
/** @var User|null $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $entity->getCreatedBy()->getId());
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $entity->getCreatedBy()->getId());
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new Error("Export entity '{$id}', user not found.");
|
throw new Error("Export entity '$id', user not found.");
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ class Service
|
|||||||
public function importById(string $id, bool $startFromLastIndex = false, bool $forceResume = false): Result
|
public function importById(string $id, bool $startFromLastIndex = false, bool $forceResume = false): Result
|
||||||
{
|
{
|
||||||
/** @var ?ImportEntity $import */
|
/** @var ?ImportEntity $import */
|
||||||
$import = $this->entityManager->getEntity(ImportEntity::ENTITY_TYPE, $id);
|
$import = $this->entityManager->getEntityById(ImportEntity::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if (!$import) {
|
if (!$import) {
|
||||||
throw new NotFound("Import '$id' not found.");
|
throw new NotFound("Import '$id' not found.");
|
||||||
|
|||||||
@@ -117,7 +117,7 @@ class ConfirmationSender
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @var ?LeadCaptureEntity $leadCapture */
|
/** @var ?LeadCaptureEntity $leadCapture */
|
||||||
$leadCapture = $this->entityManager->getEntity(LeadCaptureEntity::ENTITY_TYPE, $leadCaptureId);
|
$leadCapture = $this->entityManager->getEntityById(LeadCaptureEntity::ENTITY_TYPE, $leadCaptureId);
|
||||||
|
|
||||||
if (!$leadCapture) {
|
if (!$leadCapture) {
|
||||||
throw new Error("LeadCapture: LeadCapture not found.");
|
throw new Error("LeadCapture: LeadCapture not found.");
|
||||||
|
|||||||
@@ -35,7 +35,6 @@ use Espo\Core\Acl\Table;
|
|||||||
use Espo\Tools\Stream\Service as StreamService;
|
use Espo\Tools\Stream\Service as StreamService;
|
||||||
|
|
||||||
use Espo\ORM\EntityManager;
|
use Espo\ORM\EntityManager;
|
||||||
use Espo\ORM\Collection;
|
|
||||||
use Espo\ORM\SthCollection;
|
use Espo\ORM\SthCollection;
|
||||||
use Espo\ORM\EntityCollection;
|
use Espo\ORM\EntityCollection;
|
||||||
|
|
||||||
@@ -278,7 +277,7 @@ class NoteHookProcessor
|
|||||||
$notifyUserIdList = [];
|
$notifyUserIdList = [];
|
||||||
|
|
||||||
foreach ($targetTeamIdList as $teamId) {
|
foreach ($targetTeamIdList as $teamId) {
|
||||||
$team = $this->entityManager->getEntity(Team::ENTITY_TYPE, $teamId);
|
$team = $this->entityManager->getEntityById(Team::ENTITY_TYPE, $teamId);
|
||||||
|
|
||||||
if (!$team) {
|
if (!$team) {
|
||||||
continue;
|
continue;
|
||||||
@@ -316,7 +315,7 @@ class NoteHookProcessor
|
|||||||
$notifyUserIdList = [];
|
$notifyUserIdList = [];
|
||||||
|
|
||||||
foreach ($targetPortalIdList as $portalId) {
|
foreach ($targetPortalIdList as $portalId) {
|
||||||
$portal = $this->entityManager->getEntity(Portal::ENTITY_TYPE, $portalId);
|
$portal = $this->entityManager->getEntityById(Portal::ENTITY_TYPE, $portalId);
|
||||||
|
|
||||||
if (!$portal) {
|
if (!$portal) {
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@@ -106,10 +106,7 @@ class NoteMentionHookProcessor
|
|||||||
$mentionCount = 0;
|
$mentionCount = 0;
|
||||||
|
|
||||||
$parent = $note->getParentId() && $note->getParentType() ?
|
$parent = $note->getParentId() && $note->getParentType() ?
|
||||||
$this->entityManager->getEntity(
|
$this->entityManager->getEntityById($note->getParentType(), $note->getParentId()) :
|
||||||
$note->getParentType(),
|
|
||||||
$note->getParentId()
|
|
||||||
) :
|
|
||||||
null;
|
null;
|
||||||
|
|
||||||
foreach ($matchList as $item) {
|
foreach ($matchList as $item) {
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class ControlFollowers implements Job
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity($entityType, $entityId);
|
$entity = $this->entityManager->getEntityById($entityType, $entityId);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ class RemoveRecoveryRequest implements Job
|
|||||||
throw new RuntimeException();
|
throw new RuntimeException();
|
||||||
}
|
}
|
||||||
|
|
||||||
$entity = $this->entityManager->getEntity(PasswordChangeRequest::ENTITY_TYPE, $id);
|
$entity = $this->entityManager->getEntityById(PasswordChangeRequest::ENTITY_TYPE, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -30,40 +30,27 @@
|
|||||||
namespace Espo\Tools\UserSecurity\TwoFactor;
|
namespace Espo\Tools\UserSecurity\TwoFactor;
|
||||||
|
|
||||||
use Espo\Core\Authentication\TwoFactor\Email\EmailLogin;
|
use Espo\Core\Authentication\TwoFactor\Email\EmailLogin;
|
||||||
use Espo\Core\Exceptions\Error;
|
|
||||||
use Espo\Core\Exceptions\Forbidden;
|
use Espo\Core\Exceptions\Forbidden;
|
||||||
use Espo\Core\Exceptions\NotFound;
|
use Espo\Core\Exceptions\NotFound;
|
||||||
|
use Espo\Core\Mail\Exceptions\SendingError;
|
||||||
use Espo\Core\Utils\Config;
|
use Espo\Core\Utils\Config;
|
||||||
use Espo\Core\Authentication\TwoFactor\Email\Util;
|
use Espo\Core\Authentication\TwoFactor\Email\Util;
|
||||||
|
|
||||||
use Espo\ORM\EntityManager;
|
use Espo\ORM\EntityManager;
|
||||||
|
|
||||||
use Espo\Entities\User;
|
use Espo\Entities\User;
|
||||||
|
|
||||||
class EmailService
|
class EmailService
|
||||||
{
|
{
|
||||||
private Util $util;
|
|
||||||
private User $user;
|
|
||||||
private EntityManager $entityManager;
|
|
||||||
private Config $config;
|
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
Util $util,
|
private Util $util,
|
||||||
User $user,
|
private User $user,
|
||||||
EntityManager $entityManager,
|
private EntityManager $entityManager,
|
||||||
Config $config
|
private Config $config
|
||||||
) {
|
) {}
|
||||||
$this->util = $util;
|
|
||||||
$this->user = $user;
|
|
||||||
$this->entityManager = $entityManager;
|
|
||||||
$this->config = $config;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @throws Forbidden
|
* @throws Forbidden
|
||||||
* @throws NotFound
|
* @throws NotFound
|
||||||
* @throws Error
|
* @throws SendingError
|
||||||
*/
|
*/
|
||||||
public function sendCode(string $userId, string $emailAddress): void
|
public function sendCode(string $userId, string $emailAddress): void
|
||||||
{
|
{
|
||||||
@@ -74,7 +61,7 @@ class EmailService
|
|||||||
$this->checkAllowed();
|
$this->checkAllowed();
|
||||||
|
|
||||||
/** @var ?User $user */
|
/** @var ?User $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class SmsService
|
|||||||
$this->checkAllowed();
|
$this->checkAllowed();
|
||||||
|
|
||||||
/** @var ?User $user */
|
/** @var ?User $user */
|
||||||
$user = $this->entityManager->getEntity(User::ENTITY_TYPE, $userId);
|
$user = $this->entityManager->getEntityById(User::ENTITY_TYPE, $userId);
|
||||||
|
|
||||||
if (!$user) {
|
if (!$user) {
|
||||||
throw new NotFound();
|
throw new NotFound();
|
||||||
|
|||||||
@@ -483,7 +483,7 @@ class Installer
|
|||||||
$em = $this->getEntityManager();
|
$em = $this->getEntityManager();
|
||||||
|
|
||||||
if ($id) {
|
if ($id) {
|
||||||
$entity = $em->getEntity($entityType, $id);
|
$entity = $em->getEntityById($entityType, $id);
|
||||||
|
|
||||||
if (!$entity) {
|
if (!$entity) {
|
||||||
$selectQuery = $em->getQueryBuilder()
|
$selectQuery = $em->getQueryBuilder()
|
||||||
|
|||||||
@@ -118,7 +118,7 @@ class ActionTest extends \tests\integration\Core\BaseTestCase
|
|||||||
$account2 = $this->entityManager->createEntity('Account', []);
|
$account2 = $this->entityManager->createEntity('Account', []);
|
||||||
|
|
||||||
/* @var $contact1 Contact */
|
/* @var $contact1 Contact */
|
||||||
$contact1 = $this->entityManager->getEntity('Contact');
|
$contact1 = $this->entityManager->getNewEntity('Contact');
|
||||||
|
|
||||||
$emailAddressGroup1 = $contact1->getEmailAddressGroup()
|
$emailAddressGroup1 = $contact1->getEmailAddressGroup()
|
||||||
->withAdded(EmailAddress::create('c1a@test.com'))
|
->withAdded(EmailAddress::create('c1a@test.com'))
|
||||||
@@ -137,7 +137,7 @@ class ActionTest extends \tests\integration\Core\BaseTestCase
|
|||||||
$contact1->set('teamsIds', [$team1->getId()]);
|
$contact1->set('teamsIds', [$team1->getId()]);
|
||||||
|
|
||||||
/* @var $contact2 Contact */
|
/* @var $contact2 Contact */
|
||||||
$contact2 = $this->entityManager->getEntity('Contact');
|
$contact2 = $this->entityManager->getNewEntity('Contact');
|
||||||
|
|
||||||
$emailAddressGroup2 = $contact1->getEmailAddressGroup()
|
$emailAddressGroup2 = $contact1->getEmailAddressGroup()
|
||||||
->withAdded(EmailAddress::create('c2a@test.com'))
|
->withAdded(EmailAddress::create('c2a@test.com'))
|
||||||
@@ -205,8 +205,8 @@ class ActionTest extends \tests\integration\Core\BaseTestCase
|
|||||||
$this->action->process($request);
|
$this->action->process($request);
|
||||||
|
|
||||||
/* @var $contact1Reloaded Contact */
|
/* @var $contact1Reloaded Contact */
|
||||||
$contact1Reloaded = $this->entityManager->getEntity('Contact', $contact1->getId());
|
$contact1Reloaded = $this->entityManager->getEntityById('Contact', $contact1->getId());
|
||||||
$contact2Reloaded = $this->entityManager->getEntity('Contact', $contact2->getId());
|
$contact2Reloaded = $this->entityManager->getEntityById('Contact', $contact2->getId());
|
||||||
|
|
||||||
$this->assertEquals('merged', $contact1Reloaded->get('description'));
|
$this->assertEquals('merged', $contact1Reloaded->get('description'));
|
||||||
|
|
||||||
@@ -247,7 +247,7 @@ class ActionTest extends \tests\integration\Core\BaseTestCase
|
|||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
$contact1->getId(),
|
$contact1->getId(),
|
||||||
$this->entityManager
|
$this->entityManager
|
||||||
->getEntity('Note', $note2->getId())
|
->getEntityById('Note', $note2->getId())
|
||||||
->get('parentId')
|
->get('parentId')
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class MassActionTest extends \tests\integration\Core\BaseTestCase
|
|||||||
|
|
||||||
$this->action->process($request);
|
$this->action->process($request);
|
||||||
|
|
||||||
$accountReloaded = $this->entityManager->getEntity('Account', $account->getId());
|
$accountReloaded = $this->entityManager->getEntityById('Account', $account->getId());
|
||||||
|
|
||||||
$this->assertEquals($adminUser->getId(), $accountReloaded->get('assignedUserId'));
|
$this->assertEquals($adminUser->getId(), $accountReloaded->get('assignedUserId'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ class EmailAddressTest extends BaseTestCase
|
|||||||
'emailAddress' => 'test@test.com',
|
'emailAddress' => 'test@test.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group1 EmailAddressGroup */
|
/* @var $group1 EmailAddressGroup */
|
||||||
$group1 = $contact->getEmailAddressGroup();
|
$group1 = $contact->getEmailAddressGroup();
|
||||||
@@ -71,7 +71,7 @@ class EmailAddressTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($contact);
|
$entityManager->saveEntity($contact);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group3 EmailAddressGroup */
|
/* @var $group3 EmailAddressGroup */
|
||||||
$group3 = $contact->getEmailAddressGroup();
|
$group3 = $contact->getEmailAddressGroup();
|
||||||
@@ -90,7 +90,7 @@ class EmailAddressTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($contact);
|
$entityManager->saveEntity($contact);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group5 EmailAddressGroup */
|
/* @var $group5 EmailAddressGroup */
|
||||||
$group5 = $contact->getEmailAddressGroup();
|
$group5 = $contact->getEmailAddressGroup();
|
||||||
@@ -111,7 +111,7 @@ class EmailAddressTest extends BaseTestCase
|
|||||||
'emailAddress' => 'test@test.com',
|
'emailAddress' => 'test@test.com',
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$contactFetched = $entityManager->getEntity('Contact', $contact->getId());
|
$contactFetched = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group EmailAddressGroup */
|
/* @var $group EmailAddressGroup */
|
||||||
$group = $contactFetched->getEmailAddressGroup();
|
$group = $contactFetched->getEmailAddressGroup();
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ class FileTest extends \tests\integration\Core\BaseTestCase
|
|||||||
'fileId' => $attachment1->getId(),
|
'fileId' => $attachment1->getId(),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$attachment1 = $entityManager->getEntity('Attachment', $attachment1->getId());
|
$attachment1 = $entityManager->getEntityById('Attachment', $attachment1->getId());
|
||||||
|
|
||||||
$this->assertEquals($document->getId(), $attachment1->get('relatedId'));
|
$this->assertEquals($document->getId(), $attachment1->get('relatedId'));
|
||||||
|
|
||||||
@@ -62,11 +62,11 @@ class FileTest extends \tests\integration\Core\BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($document);
|
$entityManager->saveEntity($document);
|
||||||
|
|
||||||
$attachment2 = $entityManager->getEntity('Attachment', $attachment2->getId());
|
$attachment2 = $entityManager->getEntityById('Attachment', $attachment2->getId());
|
||||||
|
|
||||||
$this->assertEquals($document->getId(), $attachment2->get('relatedId'));
|
$this->assertEquals($document->getId(), $attachment2->get('relatedId'));
|
||||||
|
|
||||||
$attachment1 = $entityManager->getEntity('Attachment', $attachment1->getId());
|
$attachment1 = $entityManager->getEntityById('Attachment', $attachment1->getId());
|
||||||
|
|
||||||
$this->assertNull($attachment1);
|
$this->assertNull($attachment1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -45,13 +45,13 @@ class PhoneNumberTest extends BaseTestCase
|
|||||||
{
|
{
|
||||||
$entityManager = $this->getContainer()->getByClass(EntityManager::class);
|
$entityManager = $this->getContainer()->getByClass(EntityManager::class);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity(Contact::ENTITY_TYPE);
|
$contact = $entityManager->getNewEntity(Contact::ENTITY_TYPE);
|
||||||
$contact->set('phoneNumber', '+1');
|
$contact->set('phoneNumber', '+1');
|
||||||
$entityManager->saveEntity($contact);
|
$entityManager->saveEntity($contact);
|
||||||
|
|
||||||
$this->assertEquals('+1', $contact->get('phoneNumber'));
|
$this->assertEquals('+1', $contact->get('phoneNumber'));
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group1 PhoneNumberGroup */
|
/* @var $group1 PhoneNumberGroup */
|
||||||
$group1 = $contact->getPhoneNumberGroup();
|
$group1 = $contact->getPhoneNumberGroup();
|
||||||
@@ -73,7 +73,7 @@ class PhoneNumberTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($contact);
|
$entityManager->saveEntity($contact);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group3 PhoneNumberGroup */
|
/* @var $group3 PhoneNumberGroup */
|
||||||
$group3 = $contact->getPhoneNumberGroup();
|
$group3 = $contact->getPhoneNumberGroup();
|
||||||
@@ -93,7 +93,7 @@ class PhoneNumberTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($contact);
|
$entityManager->saveEntity($contact);
|
||||||
|
|
||||||
$contact = $entityManager->getEntity('Contact', $contact->getId());
|
$contact = $entityManager->getEntityById('Contact', $contact->getId());
|
||||||
|
|
||||||
/* @var $group5 PhoneNumberGroup */
|
/* @var $group5 PhoneNumberGroup */
|
||||||
$group5 = $contact->getPhoneNumberGroup();
|
$group5 = $contact->getPhoneNumberGroup();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ class RelationTest extends BaseTestCase
|
|||||||
],
|
],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
$opportunity = $entityManager->getEntity('Opportunity', $opportunity->getId());
|
$opportunity = $entityManager->getEntityById('Opportunity', $opportunity->getId());
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
self::sortArray([
|
self::sortArray([
|
||||||
@@ -91,7 +91,7 @@ class RelationTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($opportunity);
|
$entityManager->saveEntity($opportunity);
|
||||||
|
|
||||||
$opportunity = $entityManager->getEntity('Opportunity', $opportunity->getId());
|
$opportunity = $entityManager->getEntityById('Opportunity', $opportunity->getId());
|
||||||
|
|
||||||
$this->assertEquals(
|
$this->assertEquals(
|
||||||
self::sortArray([
|
self::sortArray([
|
||||||
@@ -108,7 +108,7 @@ class RelationTest extends BaseTestCase
|
|||||||
|
|
||||||
$this->assertEquals('Evaluator', $column3);
|
$this->assertEquals('Evaluator', $column3);
|
||||||
|
|
||||||
$opportunity = $entityManager->getEntity('Opportunity', $opportunity->getId());
|
$opportunity = $entityManager->getEntityById('Opportunity', $opportunity->getId());
|
||||||
|
|
||||||
$opportunity->set([
|
$opportunity->set([
|
||||||
'contactsColumns' => (object) [
|
'contactsColumns' => (object) [
|
||||||
@@ -179,11 +179,11 @@ class RelationTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($lead2);
|
$entityManager->saveEntity($lead2);
|
||||||
|
|
||||||
$lead1 = $entityManager->getEntity('Lead', $lead1->getId());
|
$lead1 = $entityManager->getEntityById('Lead', $lead1->getId());
|
||||||
|
|
||||||
$this->assertNull($lead1->get('createdAccountId'));
|
$this->assertNull($lead1->get('createdAccountId'));
|
||||||
|
|
||||||
$lead2 = $entityManager->getEntity('Lead', $lead2->getId());
|
$lead2 = $entityManager->getEntityById('Lead', $lead2->getId());
|
||||||
|
|
||||||
$this->assertEquals($account->getId(), $lead2->get('createdAccountId'));
|
$this->assertEquals($account->getId(), $lead2->get('createdAccountId'));
|
||||||
}
|
}
|
||||||
@@ -202,7 +202,7 @@ class RelationTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($account);
|
$entityManager->saveEntity($account);
|
||||||
|
|
||||||
$account = $entityManager->getEntity('Account', $account->getId());
|
$account = $entityManager->getEntityById('Account', $account->getId());
|
||||||
|
|
||||||
$account->set([
|
$account->set([
|
||||||
'originalLeadId' => $lead2->getId(),
|
'originalLeadId' => $lead2->getId(),
|
||||||
@@ -210,11 +210,11 @@ class RelationTest extends BaseTestCase
|
|||||||
|
|
||||||
$entityManager->saveEntity($account);
|
$entityManager->saveEntity($account);
|
||||||
|
|
||||||
$lead2 = $entityManager->getEntity('Lead', $lead2->getId());
|
$lead2 = $entityManager->getEntityById('Lead', $lead2->getId());
|
||||||
|
|
||||||
$this->assertEquals($account->getId(), $lead2->get('createdAccountId'));
|
$this->assertEquals($account->getId(), $lead2->get('createdAccountId'));
|
||||||
|
|
||||||
$lead1 = $entityManager->getEntity('Lead', $lead1->getId());
|
$lead1 = $entityManager->getEntityById('Lead', $lead1->getId());
|
||||||
|
|
||||||
$this->assertEquals(null, $lead1->get('createdAccountId'));
|
$this->assertEquals(null, $lead1->get('createdAccountId'));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -42,11 +42,7 @@ use Espo\Entities\Email;
|
|||||||
use Espo\Modules\Crm\Entities\Account;
|
use Espo\Modules\Crm\Entities\Account;
|
||||||
use Espo\Modules\Crm\Entities\Opportunity;
|
use Espo\Modules\Crm\Entities\Opportunity;
|
||||||
use Espo\ORM\EntityManager;
|
use Espo\ORM\EntityManager;
|
||||||
use Espo\ORM\Query\Part\Condition;
|
|
||||||
use Espo\ORM\Query\Part\Expression;
|
|
||||||
use Espo\ORM\Query\Part\WhereClause;
|
|
||||||
use Espo\ORM\Query\Select;
|
use Espo\ORM\Query\Select;
|
||||||
use Espo\ORM\Query\SelectBuilder;
|
|
||||||
use tests\integration\Core\BaseTestCase;
|
use tests\integration\Core\BaseTestCase;
|
||||||
|
|
||||||
class SelectBuilderTest extends BaseTestCase
|
class SelectBuilderTest extends BaseTestCase
|
||||||
@@ -950,7 +946,7 @@ class SelectBuilderTest extends BaseTestCase
|
|||||||
|
|
||||||
$em = $container->getByClass(EntityManager::class);
|
$em = $container->getByClass(EntityManager::class);
|
||||||
|
|
||||||
$user = $em->getEntity('User', $userId);
|
$user = $em->getEntityById('User', $userId);
|
||||||
|
|
||||||
$emailAddress = $em->createEntity('EmailAddress', [
|
$emailAddress = $em->createEntity('EmailAddress', [
|
||||||
'name' => 'test@test.com',
|
'name' => 'test@test.com',
|
||||||
|
|||||||
@@ -121,16 +121,16 @@ class ExportTest extends \tests\integration\Core\BaseTestCase
|
|||||||
->run()
|
->run()
|
||||||
->getAttachmentId();
|
->getAttachmentId();
|
||||||
|
|
||||||
$attachment = $this->entityManager->getEntity('Attachment', $attachmentId);
|
$attachment = $this->entityManager->getEntityById('Attachment', $attachmentId);
|
||||||
|
|
||||||
$contents = $this->fileStorageManager->getContents($attachment);
|
$contents = $this->fileStorageManager->getContents($attachment);
|
||||||
|
|
||||||
$exepectedContents =
|
$expectedContents =
|
||||||
"name,assignedUserId,assignedUserName\n" .
|
"name,assignedUserId,assignedUserName\n" .
|
||||||
"test-2,user-id,User\n" .
|
"test-2,user-id,User\n" .
|
||||||
"test-1,user-id,User\n";
|
"test-1,user-id,User\n";
|
||||||
|
|
||||||
$this->assertEquals($exepectedContents, $contents);
|
$this->assertEquals($expectedContents, $contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCsvWithAttributeList(): void
|
public function testCsvWithAttributeList(): void
|
||||||
@@ -170,16 +170,16 @@ class ExportTest extends \tests\integration\Core\BaseTestCase
|
|||||||
->run()
|
->run()
|
||||||
->getAttachmentId();
|
->getAttachmentId();
|
||||||
|
|
||||||
$attachment = $this->entityManager->getEntity('Attachment', $attachmentId);
|
$attachment = $this->entityManager->getEntityById('Attachment', $attachmentId);
|
||||||
|
|
||||||
$contents = $this->fileStorageManager->getContents($attachment);
|
$contents = $this->fileStorageManager->getContents($attachment);
|
||||||
|
|
||||||
$exepectedContents =
|
$expectedContents =
|
||||||
"id,name,assignedUserId\n" .
|
"id,name,assignedUserId\n" .
|
||||||
"2,test-2,user-id\n" .
|
"2,test-2,user-id\n" .
|
||||||
"1,test-1,user-id\n";
|
"1,test-1,user-id\n";
|
||||||
|
|
||||||
$this->assertEquals($exepectedContents, $contents);
|
$this->assertEquals($expectedContents, $contents);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testCsvCollection(): void
|
public function testCsvCollection(): void
|
||||||
@@ -235,15 +235,15 @@ class ExportTest extends \tests\integration\Core\BaseTestCase
|
|||||||
->run()
|
->run()
|
||||||
->getAttachmentId();
|
->getAttachmentId();
|
||||||
|
|
||||||
$attachment = $this->entityManager->getEntity('Attachment', $attachmentId);
|
$attachment = $this->entityManager->getEntityById('Attachment', $attachmentId);
|
||||||
|
|
||||||
$contents = $this->fileStorageManager->getContents($attachment);
|
$contents = $this->fileStorageManager->getContents($attachment);
|
||||||
|
|
||||||
$exepectedContents =
|
$expectedContents =
|
||||||
"name,assignedUserId\n" .
|
"name,assignedUserId\n" .
|
||||||
"test-1,user-id\n" .
|
"test-1,user-id\n" .
|
||||||
"test-2,user-id\n";
|
"test-2,user-id\n";
|
||||||
|
|
||||||
$this->assertEquals($exepectedContents, $contents);
|
$this->assertEquals($expectedContents, $contents);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -95,7 +95,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase
|
|||||||
|
|
||||||
$em->saveEntity($opportunity);
|
$em->saveEntity($opportunity);
|
||||||
|
|
||||||
$note1 = $em->getEntity('Note', $note1->getId());
|
$note1 = $em->getEntityById('Note', $note1->getId());
|
||||||
|
|
||||||
$this->assertEquals([$team2->getId()], $note1->getLinkMultipleIdList('teams'));
|
$this->assertEquals([$team2->getId()], $note1->getLinkMultipleIdList('teams'));
|
||||||
$this->assertEquals([$user2->getId()], $note1->getLinkMultipleIdList('users'));
|
$this->assertEquals([$user2->getId()], $note1->getLinkMultipleIdList('users'));
|
||||||
@@ -130,7 +130,7 @@ class AclTest extends \tests\integration\Core\BaseTestCase
|
|||||||
|
|
||||||
$em->saveEntity($meeting);
|
$em->saveEntity($meeting);
|
||||||
|
|
||||||
$note2 = $em->getEntity('Note', $note2->getId());
|
$note2 = $em->getEntityById('Note', $note2->getId());
|
||||||
|
|
||||||
$this->assertEquals([$team2->getId()], $note2->getLinkMultipleIdList('teams'));
|
$this->assertEquals([$team2->getId()], $note2->getLinkMultipleIdList('teams'));
|
||||||
$this->assertEquals([$user2->getId()], $note2->getLinkMultipleIdList('users'));
|
$this->assertEquals([$user2->getId()], $note2->getLinkMultipleIdList('users'));
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ class RelationsTest extends BaseTestCase
|
|||||||
|
|
||||||
$em = $this->getEntityManager();
|
$em = $this->getEntityManager();
|
||||||
|
|
||||||
$opp = $em->getEntity(Opportunity::ENTITY_TYPE);
|
$opp = $em->getNewEntity(Opportunity::ENTITY_TYPE);
|
||||||
$this->assertInstanceOf(OpportunityExtended::class, $opp);
|
$this->assertInstanceOf(OpportunityExtended::class, $opp);
|
||||||
$this->assertNull($opp->getRelatedAccount());
|
$this->assertNull($opp->getRelatedAccount());
|
||||||
|
|
||||||
@@ -98,7 +98,7 @@ class RelationsTest extends BaseTestCase
|
|||||||
|
|
||||||
$em = $this->getEntityManager();
|
$em = $this->getEntityManager();
|
||||||
|
|
||||||
$account = $em->getEntity(Account::ENTITY_TYPE);
|
$account = $em->getNewEntity(Account::ENTITY_TYPE);
|
||||||
$this->assertInstanceOf(AccountExtended::class, $account);
|
$this->assertInstanceOf(AccountExtended::class, $account);
|
||||||
$this->assertInstanceOf(EntityCollection::class, $account->getRelatedOpportunities());
|
$this->assertInstanceOf(EntityCollection::class, $account->getRelatedOpportunities());
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user