cleanup and cs fixes

This commit is contained in:
Yuri Kuznetsov
2021-07-09 10:57:16 +03:00
parent 8ff262456b
commit 949149ea4d
5 changed files with 45 additions and 57 deletions
+1 -11
View File
@@ -52,16 +52,6 @@ class Event extends Database implements
protected $preserveDuration = true;
protected function getConfig()
{
return $this->config;
}
protected function getDateTime()
{
return $this->dateTime;
}
protected function beforeSave(Entity $entity, array $options = [])
{
if (
@@ -156,7 +146,7 @@ class Event extends Database implements
protected function convertDateTimeToDefaultTimezone($string)
{
$timeZone = $this->getConfig()->get('timeZone') ?? 'UTC';
$timeZone = $this->config->get('timeZone') ?? 'UTC';
$tz = new DateTimeZone($timeZone);
@@ -29,7 +29,6 @@
namespace Espo\Core\Templates\Repositories;
class Event extends \Espo\Core\Repositories\Event
{
use Espo\Core\Repositories\Event as BaseEvent;
}
class Event extends BaseEvent {}
@@ -29,10 +29,4 @@
namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
class Call extends Meeting
{
}
class Call extends Meeting {}
@@ -30,11 +30,13 @@
namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
use Espo\Core\Utils\Util;
use Espo\Core\Repositories\Event as EventRepository;
use Espo\Core\Di;
class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, Di\UserAware
class Meeting extends EventRepository implements
Di\ConfigAware,
Di\UserAware
{
use Di\ConfigSetter;
use Di\UserSetter;
@@ -61,8 +63,10 @@ class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, D
$entity->getLinkMultipleName('assignedUsers', $assignedUserId)
);
}
} else {
}
else {
$assignedUserId = $entity->get('assignedUserId');
if ($assignedUserId) {
$entity->addLinkMultipleId('users', $assignedUserId);
$entity->setLinkMultipleName('users', $assignedUserId, $entity->get('assignedUserName'));
@@ -73,11 +77,9 @@ class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, D
if ($entity->isNew()) {
$currentUserId = $this->user->id;
if (
$entity->hasLinkMultipleId('users', $currentUserId)
&&
$entity->hasLinkMultipleId('users', $currentUserId) &&
(
!$entity->getLinkMultipleColumn('users', 'status', $currentUserId)
||
!$entity->getLinkMultipleColumn('users', 'status', $currentUserId) ||
$entity->getLinkMultipleColumn('users', 'status', $currentUserId) === 'None'
)
) {
@@ -86,7 +88,7 @@ class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, D
}
}
protected function processParentChanged(Entity $entity)
protected function processParentChanged(Entity $entity): void
{
$parent = null;
@@ -123,13 +125,13 @@ class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, D
$accountId = $parent->id;
$accountName = $parent->get('name');
}
else if ($parent->getEntityType() == 'Lead') {
if ($parent->get('status') == 'Converted') {
if ($parent->get('createdAccountId')) {
$accountId = $parent->get('createdAccountId');
$accountName = $parent->get('createdAccountName');
}
}
else if (
$parent->getEntityType() == 'Lead' &&
$parent->get('status') == 'Converted' &&
$parent->get('createdAccountId')
) {
$accountId = $parent->get('createdAccountId');
$accountName = $parent->get('createdAccountName');
}
if (
@@ -146,8 +148,7 @@ class Meeting extends \Espo\Core\Repositories\Event implements Di\ConfigAware, D
}
if (
$entity->get('accountId')
&&
$entity->get('accountId') &&
!$entity->get('accountName')
) {
$account = $this->entityManager
@@ -30,8 +30,9 @@
namespace Espo\Modules\Crm\Repositories;
use Espo\ORM\Entity;
use Espo\Core\Repositories\Event as EventRepository;
class Task extends \Espo\Core\Repositories\Event
class Task extends EventRepository
{
protected $reminderSkippingStatusList = ['Completed', 'Canceled'];
@@ -61,7 +62,7 @@ class Task extends \Espo\Core\Repositories\Event
parent::beforeSave($entity, $options);
}
protected function processParentChanged(Entity $entity)
protected function processParentChanged(Entity $entity): void
{
$parent = null;
@@ -106,16 +107,15 @@ class Task extends \Espo\Core\Repositories\Event
$accountId = $parent->id;
$accountName = $parent->get('name');
}
else if ($parent->getEntityType() == 'Lead') {
if ($parent->get('status') == 'Converted') {
if ($parent->get('createdAccountId')) {
$accountId = $parent->get('createdAccountId');
$accountName = $parent->get('createdAccountName');
}
if ($parent->get('createdContactId')) {
$contactId = $parent->get('createdContactId');
$contactName = $parent->get('createdContactName');
}
else if ($parent->getEntityType() == 'Lead' && $parent->get('status') == 'Converted') {
if ($parent->get('createdAccountId')) {
$accountId = $parent->get('createdAccountId');
$accountName = $parent->get('createdAccountName');
}
if ($parent->get('createdContactId')) {
$contactId = $parent->get('createdContactId');
$contactName = $parent->get('createdContactName');
}
}
else if ($parent->getEntityType() == 'Contact') {
@@ -123,11 +123,17 @@ class Task extends \Espo\Core\Repositories\Event
$contactName = $parent->get('name');
}
if (!$accountId && $parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account') {
if (
!$accountId &&
$parent->get('accountId') && $parent->getRelationParam('account', 'entity') == 'Account'
) {
$accountId = $parent->get('accountId');
}
if (!$contactId && $parent->get('contactId') && $parent->getRelationParam('contact', 'entity') == 'Contact') {
if (
!$contactId &&
$parent->get('contactId') && $parent->getRelationParam('contact', 'entity') == 'Contact'
) {
$contactId = $parent->get('contactId');
}
}
@@ -139,8 +145,7 @@ class Task extends \Espo\Core\Repositories\Event
$entity->set('contactName', $contactName);
if (
$entity->get('accountId')
&&
$entity->get('accountId') &&
!$entity->get('accountName')
) {
$account = $this->entityManager
@@ -155,8 +160,7 @@ class Task extends \Espo\Core\Repositories\Event
}
if (
$entity->get('contactId')
&&
$entity->get('contactId') &&
!$entity->get('contactName')
) {
$contact = $this->entityManager