This commit is contained in:
Yuri Kuznetsov
2021-11-09 17:46:54 +02:00
parent 7499703d77
commit c8bed9af32
22 changed files with 53 additions and 20 deletions

View File

@@ -47,12 +47,13 @@ class DefaultRoleListProvider implements RoleListProvider
}
/**
* @return array<int, Role>
* @return Role[]
*/
public function get(): array
{
$roleList = [];
/** @var iterable<RoleEntity> */
$userRoleList = $this->entityManager
->getRDBRepository('User')
->getRelation($this->user, 'roles')
@@ -69,6 +70,7 @@ class DefaultRoleListProvider implements RoleListProvider
->find();
foreach ($teamList as $team) {
/** @var iterable<RoleEntity> */
$teamRoleList = $this->entityManager
->getRDBRepository('Team')
->getRelation($team, 'roles')

View File

@@ -34,8 +34,9 @@ use Espo\Core\Exceptions\Error;
use Espo\Entities\Integration as IntegrationEntity;
use Espo\Entities\ExternalAccount as ExternalAccountEntity;
use Espo\ORM\EntityManager;
use Espo\Core\{
ORM\EntityManager,
Utils\Metadata,
Utils\Config,
InjectableFactory,

View File

@@ -65,6 +65,7 @@ class RoleListProvider implements RoleListProviderInterface
{
$roleList = [];
/** @var iterable<PortalRole> */
$userRoleList = $this->entityManager
->getRDBRepository('User')
->getRelation($this->user, 'portalRoles')
@@ -74,6 +75,7 @@ class RoleListProvider implements RoleListProviderInterface
$roleList[] = $role;
}
/** @var iterable<PortalRole> */
$portalRoleList = $this->entityManager
->getRDBRepository('Portal')
->getRelation($this->portal, 'portalRoles')

View File

@@ -406,6 +406,7 @@ class Converter
}
if (!empty($uniqueIndex)) {
/** @var string[] $uniqueIndex */
$uniqueIndexName = implode('_', $uniqueIndex);
$table->addUniqueIndex(

View File

@@ -389,6 +389,7 @@ class Campaign extends \Espo\Services\Record implements
$metTargetHash = [];
$targetEntityList = [];
/** @var iterable<\Espo\Modules\Crm\Entities\TargetList> */
$excludingTargetListList = $this->getEntityManager()
->getRDBRepository('Campaign')
->getRelation($campaign, 'excludingTargetLists')
@@ -408,6 +409,7 @@ class Campaign extends \Espo\Services\Record implements
$addressFieldList = $this->entityTypeAddressFieldListMap[$targetEntityType];
/** @var iterable<\Espo\Modules\Crm\Entities\TargetList> */
$targetListCollection = $this->getEntityManager()
->getRDBRepository('Campaign')
->getRelation($campaign, 'targetLists')

View File

@@ -35,7 +35,7 @@ use Espo\{
Modules\Crm\Entities\CaseObj as CaseEntity,
};
use StdClass;
use stdClass;
class CaseObj extends Record
{
@@ -85,6 +85,7 @@ class CaseObj extends Record
public function getEmailAddressList(string $id): array
{
/** @var CaseEntity */
$entity = $this->getEntity($id);
$forbiddenFieldList = $this->acl->getScopeForbiddenFieldList($this->getEntityType());
@@ -129,7 +130,7 @@ class CaseObj extends Record
return $list;
}
protected function getAccountEmailAddress(CaseEntity $entity, array $dataList): ?StdClass
protected function getAccountEmailAddress(CaseEntity $entity, array $dataList): ?stdClass
{
$account = $this->entityManager->getEntity('Account', $entity->get('accountId'));
@@ -156,7 +157,7 @@ class CaseObj extends Record
];
}
protected function getLeadEmailAddress(CaseEntity $entity, array $dataList): ?StdClass
protected function getLeadEmailAddress(CaseEntity $entity, array $dataList): ?stdClass
{
$lead = $this->entityManager->getEntity('Account', $entity->get('leadId'));

View File

@@ -29,6 +29,8 @@
namespace Espo\Modules\Crm\Services;
use Espo\Modules\Crm\Entities\MassEmail as MassEmailEntity;
use Espo\Core\{
Exceptions\Forbidden,
Exceptions\BadRequest,
@@ -118,14 +120,14 @@ class MassEmail extends RecordService
$this->processTestSending($massEmail);
}
protected function createTestQueue(Entity $massEmail, iterable $targetList): void
protected function createTestQueue(MassEmailEntity $massEmail, iterable $targetList): void
{
$queue = $this->injectableFactory->create(Queue::class);
$queue->create($massEmail, true, $targetList);
}
protected function processTestSending(Entity $massEmail): void
protected function processTestSending(MassEmailEntity $massEmail): void
{
$processor = $this->injectableFactory->create(Processor::class);

View File

@@ -364,11 +364,11 @@ class Opportunity extends Record
$dtTo = new DateTime($dateTo);
if (intval($dtTo->format('d')) !== 1) {
$dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1);
$dtTo->setDate((int) $dtTo->format('Y'), (int) $dtTo->format('m'), 1);
$dtTo->modify('+ 1 month');
}
else {
$dtTo->setDate($dtTo->format('Y'), $dtTo->format('m'), 1);
$dtTo->setDate((int) $dtTo->format('Y'), (int) $dtTo->format('m'), 1);
}
$interval = new DateInterval('P1M');
@@ -559,6 +559,7 @@ class Opportunity extends Record
public function getEmailAddressList(string $id): array
{
/** @var OpportunityEntity */
$entity = $this->getEntity($id);
$forbiddenFieldList = $this->acl->getScopeForbiddenFieldList($this->getEntityType());

View File

@@ -113,7 +113,7 @@ trait SelectingBuilderTrait
* Passing an array will reset a previously set order.
* @param string|bool|null $direction OrderExpression::ASC|OrderExpression::DESC.
*
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]> $orderBy
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
*/
public function order($orderBy, $direction = null): self
{

View File

@@ -286,7 +286,7 @@ class RDBRelation
* Passing an array will reset a previously set order.
* @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC.
*
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]> $orderBy
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
*/
public function order($orderBy = 'id', $direction = null): Builder
{

View File

@@ -357,7 +357,7 @@ class RDBRelationSelectBuilder
* Passing an array will reset a previously set order.
* @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC.
*
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]> $orderBy
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
*/
public function order($orderBy = 'id', $direction = null): self
{

View File

@@ -847,7 +847,7 @@ class RDBRepository implements Repository
* Passing an array will reset a previously set order.
* @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC.
*
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]> $orderBy
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
* @phpstan-return RDBSelectBuilder<TEntity>
*/
public function order($orderBy = 'id', $direction = null): RDBSelectBuilder

View File

@@ -316,7 +316,7 @@ class RDBSelectBuilder
* Passing an array will reset a previously set order.
* @param string|bool|null $direction Select::ORDER_ASC|Select::ORDER_DESC.
*
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]> $orderBy
* @phpstan-param Order|Order[]|Expression|string|array<int, string[]>|string[] $orderBy
* @phpstan-return RDBSelectBuilder<TEntity>
*/
public function order($orderBy = 'id', $direction = null): self

View File

@@ -33,6 +33,7 @@ use Espo\Services\Settings as SettingsService;
use Espo\Repositories\PhoneNumber as PhoneNumberRepository;
use Espo\Repositories\ArrayValue as ArrayValueRepository;
use Espo\Core\ORM\Entity as CoreEntity;
use Espo\Core\{
Acl,
@@ -511,6 +512,10 @@ class App
while ($dataRow = $sth->fetch()) {
$entity = $this->entityManager->getEntityFactory()->create($scope);
if (!$entity instanceof CoreEntity) {
continue;
}
$entity->set($dataRow);
$entity->setAsFetched();

View File

@@ -37,6 +37,7 @@ use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\NotFound;
use Espo\Repositories\Attachment as AttachmentRepository;
use Espo\Entities\Attachment as AttachmentEntity;
use stdClass;
@@ -275,6 +276,7 @@ class Attachment extends Record
$this->checkAttachmentField($relatedEntityType, $field);
/** @var AttachmentEntity|null */
$attachment = $this->getEntity($data->id);
if (!$attachment) {
@@ -464,6 +466,7 @@ class Attachment extends Record
public function getFileData(string $id): stdClass
{
/** @var AttachmentEntity|null */
$attachment = $this->getEntity($id);
if (!$attachment) {

View File

@@ -430,6 +430,7 @@ class Email extends Record implements
public function create(stdClass $data, CreateParams $params): Entity
{
/** @var EmailEntity */
$entity = parent::create($data, $params);
if ($entity->get('status') === EmailEntity::STATUS_SENDING) {
@@ -441,6 +442,8 @@ class Email extends Record implements
protected function beforeCreateEntity(Entity $entity, $data)
{
/** @var EmailEntity $entity */
if ($entity->get('status') === EmailEntity::STATUS_SENDING) {
$messageId = Sender::generateMessageId($entity);
@@ -450,6 +453,8 @@ class Email extends Record implements
protected function afterUpdateEntity(Entity $entity, $data)
{
/** @var EmailEntity $entity */
if ($entity->get('status') === EmailEntity::STATUS_SENDING) {
$this->sendEntity($entity, $this->getUser());
}

View File

@@ -306,7 +306,7 @@ class EmailAccount extends Record implements
return $this->injectableFactory->create(Importer::class);
}
public function fetchFromMailServer(Entity $emailAccount)
public function fetchFromMailServer(EmailAccountEntity $emailAccount)
{
if ($emailAccount->get('status') != 'Active' || !$emailAccount->get('useImap')) {
throw new Error("Email Account {$emailAccount->getId()} is not active.");
@@ -622,14 +622,17 @@ class EmailAccount extends Record implements
}
}
public function findAccountForUser(User $user, $address)
/**
* @return EmailAccountEntity|null
*/
public function findAccountForUser(User $user, string $address)
{
$emailAccount = $this->entityManager
->getRDBRepository('EmailAccount')
->where([
'emailAddress' => $address,
'assignedUserId' => $user->getId(),
'status' => 'Active'
'status' => 'Active',
])
->findOne();
@@ -699,7 +702,7 @@ class EmailAccount extends Record implements
}
try {
$size = $storage->getSize($id);
$size = $storage->getSize((int) $id);
}
catch (Throwable $e) {
return false;

View File

@@ -79,6 +79,7 @@ class EmailTemplate extends Record implements
public function parse(string $id, array $params = [], bool $copyAttachments = false): array
{
/** @var EmailTemplateEntity|null */
$emailTemplate = $this->getEntity($id);
if (empty($emailTemplate)) {

View File

@@ -1318,7 +1318,7 @@ class InboundEmail extends RecordService implements
}
try {
$size = $storage->getSize($id);
$size = $storage->getSize((int) $id);
}
catch (Throwable $e) {
return false;

View File

@@ -51,6 +51,8 @@ class Note extends Record
{
parent::afterCreateEntity($entity, $data);
/** @var NoteEntity $entity */
$this->processFollowAfterCreate($entity);
}

View File

@@ -325,7 +325,7 @@ class Pdf
private function buildFromTemplateInternal(
Entity $entity,
Entity $template,
Template $template,
bool $displayInline = false,
?array $additionalData = null,
?Params $params = null,

View File

@@ -53,6 +53,8 @@ class Portal extends Record implements
protected function afterUpdateEntity(Entity $entity, $data)
{
/** @var PortalEntity $entity */
$this->loadUrlField($entity);
if (property_exists($data, 'portalRolesIds')) {