type fixes

This commit is contained in:
Yuri Kuznetsov
2022-03-12 10:59:30 +02:00
parent b4c5596b54
commit 42642de0e6
10 changed files with 43 additions and 9 deletions

View File

@@ -31,6 +31,8 @@ namespace Espo\Modules\Crm\Jobs;
use Espo\Core\ORM\Entity as CoreEntity;
use Espo\Modules\Crm\Entities\Reminder;
use Espo\Core\{
ORM\EntityManager,
Utils\Config,
@@ -80,7 +82,6 @@ class SubmitPopupReminders implements JobDataLess
$nowShifted = $dt->modify('-' . $pastHours . ' hours')->format('Y-m-d H:i:s');
/** @var iterable<\Espo\Modules\Crm\Entities\Reminder> $reminderList */
$reminderList = $this->entityManager
->getRDBRepository('Reminder')
->where([
@@ -165,7 +166,7 @@ class SubmitPopupReminders implements JobDataLess
}
}
protected function deleteReminder($reminder)
protected function deleteReminder(Reminder $reminder): void
{
$this->entityManager->getRDBRepository('Reminder')->deleteFromDb($reminder->id);
}

View File

@@ -31,6 +31,9 @@ namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\Account>
*/
class Account extends \Espo\Core\Repositories\Database
{
public function afterSave(Entity $entity, array $options = [])

View File

@@ -29,4 +29,5 @@
namespace Espo\Modules\Crm\Repositories;
class Call extends Meeting {}

View File

@@ -30,17 +30,18 @@
namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
use Espo\Services\Stream as StreamService;
use Espo\Core\Di;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\CaseObj>
*/
class CaseObj extends \Espo\Core\Repositories\Database implements
Di\ServiceFactoryAware
{
use Di\ServiceFactorySetter;
protected $streamService;
protected ?StreamService $streamService = null;
protected function afterSave(Entity $entity, array $options = [])
{

View File

@@ -31,20 +31,23 @@ namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\Lead>
*/
class Contact extends \Espo\Core\Repositories\Database
{
public function afterSave(Entity $entity, array $options = [])
{
parent::afterSave($entity, $options);
$this->handleAfterSaveAccounts($entity, $options);
$this->handleAfterSaveAccounts($entity);
if ($entity->has('targetListId')) {
$this->relate($entity, 'targetLists', $entity->get('targetListId'));
}
}
protected function handleAfterSaveAccounts(Entity $entity, array $options = [])
protected function handleAfterSaveAccounts(Entity $entity): void
{
$accountIdChanged = $entity->has('accountId') &&
$entity->get('accountId') != $entity->getFetched('accountId');

View File

@@ -29,6 +29,9 @@
namespace Espo\Modules\Crm\Repositories;
/**
* @extends \Espo\Core\Repositories\CategoryTree<\Espo\Modules\Crm\Entities\DocumentFolder>
*/
class DocumentFolder extends \Espo\Core\Repositories\CategoryTree
{
}

View File

@@ -31,18 +31,26 @@ namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\KnowledgeBaseArticle>
*/
class KnowledgeBaseArticle extends \Espo\Core\Repositories\Database
{
protected function beforeSave(Entity $entity, array $options = [])
{
parent::beforeSave($entity, $options);
$order = $entity->get('order');
if (is_null($order)) {
$order = $this->min('order');
if (!$order) {
$order = 9999;
}
$order--;
$entity->set('order', $order);
}
}

View File

@@ -29,6 +29,9 @@
namespace Espo\Modules\Crm\Repositories;
/**
* @extends \Espo\Core\Repositories\CategoryTree<\Espo\Modules\Crm\Entities\KnowledgeBaseCategory>
*/
class KnowledgeBaseCategory extends \Espo\Core\Repositories\CategoryTree
{
}

View File

@@ -31,12 +31,20 @@ namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\Lead>
*/
class Lead extends \Espo\Core\Repositories\Database
{
public function beforeSave(Entity $entity, array $options = [])
{
if (!$entity->get('convertedAt') && $entity->get('status') === 'Converted' && $entity->isAttributeChanged('status')) {
if (
!$entity->get('convertedAt') &&
$entity->get('status') === 'Converted' &&
$entity->isAttributeChanged('status')
) {
$convertedAt = date('Y-m-d H:i:s');
$entity->set('convertedAt', $convertedAt);
}
@@ -48,7 +56,7 @@ class Lead extends \Espo\Core\Repositories\Database
parent::afterSave($entity, $options);
if ($entity->has('targetListId')) {
$this->relate($entity, 'targetLists', $entity->get('targetListId'));
$this->relate($entity, 'targetLists', $entity->get('targetListId'));
}
}
}

View File

@@ -29,6 +29,9 @@
namespace Espo\Modules\Crm\Repositories;
/**
* @extends \Espo\Core\Repositories\Database<\Espo\Modules\Crm\Entities\TargetList>
*/
class TargetList extends \Espo\Core\Repositories\Database
{
}