EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
stream create related many-many fix, options constants
Yuri Kuznetsove5c2ec33714d
diff --git a/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php b/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.phpindex e915bcf4f7..ec07e32265 100644--- a/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php+++ b/application/Espo/Core/FieldProcessing/Relation/LinkMultipleSaver.php@@ -217,6 +217,7 @@ class LinkMultipleSaver$repository->getRelation($entity, $name)->relateById($id, $data, [SaveOption::SKIP_HOOKS => $skipHooks,+ SaveOption::SILENT => $entity->isNew(),self::RELATE_OPTION => $entity->hasLinkMultipleField($name),]);}diff --git a/application/Espo/Core/ORM/Repository/Option/SaveOption.php b/application/Espo/Core/ORM/Repository/Option/SaveOption.phpindex 01972148a3..67eb130355 100644--- a/application/Espo/Core/ORM/Repository/Option/SaveOption.php+++ b/application/Espo/Core/ORM/Repository/Option/SaveOption.php@@ -38,6 +38,7 @@ class SaveOption{/*** Silent. Boolean.+ * Skip stream notes, notifications, webhooks.*/public const SILENT = 'silent';/**@@ -97,4 +98,14 @@ class SaveOption* @since 8.4.0*/public const MASS_UPDATE = 'massUpdate';+ /**+ * Skip stream notes. Boolean.+ * @since 9.0.0+ */+ public const NO_STREAM = 'noStream';+ /**+ * Skip notification. Boolean.+ * @since 9.0.0+ */+ public const NO_NOTIFICATIONS = 'noNotifications';}diff --git a/application/Espo/Hooks/Common/AssignmentEmailNotification.php b/application/Espo/Hooks/Common/AssignmentEmailNotification.phpindex e5afe935ab..01ef006dff 100644--- a/application/Espo/Hooks/Common/AssignmentEmailNotification.php+++ b/application/Espo/Hooks/Common/AssignmentEmailNotification.php@@ -49,7 +49,7 @@ class AssignmentEmailNotification{if (!empty($options[SaveOption::SILENT]) ||- !empty($options['noNotifications'])+ !empty($options[SaveOption::NO_NOTIFICATIONS])) {return;}diff --git a/application/Espo/Hooks/Common/Notifications.php b/application/Espo/Hooks/Common/Notifications.phpindex aea0c46772..0312d561a3 100644--- a/application/Espo/Hooks/Common/Notifications.php+++ b/application/Espo/Hooks/Common/Notifications.php@@ -49,7 +49,7 @@ class Notifications*/public function afterSave(Entity $entity, array $options): void{- if (!empty($options[SaveOption::SILENT]) || !empty($options['noNotifications'])) {+ if (!empty($options[SaveOption::SILENT]) || !empty($options[SaveOption::NO_NOTIFICATIONS])) {return;}@@ -61,7 +61,7 @@ class Notifications*/public function beforeRemove(Entity $entity, array $options): void{- if (!empty($options[SaveOption::SILENT]) || !empty($options['noNotifications'])) {+ if (!empty($options[SaveOption::SILENT]) || !empty($options[SaveOption::NO_NOTIFICATIONS])) {return;}diff --git a/application/Espo/Hooks/Common/StreamNotesAcl.php b/application/Espo/Hooks/Common/StreamNotesAcl.phpindex e85dfd87aa..b3b08d20d7 100644--- a/application/Espo/Hooks/Common/StreamNotesAcl.php+++ b/application/Espo/Hooks/Common/StreamNotesAcl.php@@ -54,7 +54,7 @@ class StreamNotesAcl*/public function afterSave(Entity $entity, array $options): void{- if (!empty($options['noStream'])) {+ if (!empty($options[SaveOption::NO_STREAM])) {return;}diff --git a/application/Espo/Tools/Import/Import.php b/application/Espo/Tools/Import/Import.phpindex ff121b0a27..c43195d447 100644--- a/application/Espo/Tools/Import/Import.php+++ b/application/Espo/Tools/Import/Import.php@@ -578,8 +578,8 @@ class Import}$this->entityManager->saveEntity($entity, [- 'noStream' => true,- 'noNotifications' => true,+ SaveOption::NO_STREAM => true,+ SaveOption::NO_NOTIFICATIONS => true,SaveOption::IMPORT => true,SaveOption::SILENT => $params->isSilentMode(),]);diff --git a/application/Espo/Tools/Import/Service.php b/application/Espo/Tools/Import/Service.phpindex 48b4e68902..0969ca13a2 100644--- a/application/Espo/Tools/Import/Service.php+++ b/application/Espo/Tools/Import/Service.php@@ -274,8 +274,8 @@ class Service}$this->entityManager->removeEntity($entity, [- 'noStream' => true,- 'noNotifications' => true,+ SaveOption::NO_STREAM => true,+ SaveOption::NO_NOTIFICATIONS => true,SaveOption::SILENT => true,SaveOption::IMPORT => true,]);@@ -403,8 +403,8 @@ class Service$this->deleteRelations($entity);$this->entityManager->removeEntity($entity, [- 'noStream' => true,- 'noNotifications' => true,+ SaveOption::NO_STREAM => true,+ SaveOption::NO_NOTIFICATIONS => true,SaveOption::SILENT => true,SaveOption::IMPORT => true,]);diff --git a/application/Espo/Tools/Stream/HookProcessor.php b/application/Espo/Tools/Stream/HookProcessor.phpindex e371f16ee1..e2b5f41d6f 100644--- a/application/Espo/Tools/Stream/HookProcessor.php+++ b/application/Espo/Tools/Stream/HookProcessor.php@@ -57,8 +57,6 @@ use Espo\Tools\Stream\Jobs\ControlFollowers as ControlFollowersJob;*/class HookProcessor{- private const OPTION_NO_STREAM = 'noStream';-/** @var array<string, bool> */private $hasStreamCache = [];/** @var array<string, bool> */@@ -81,7 +79,7 @@ class HookProcessor{if (!$this->checkHasStream($entity->getEntityType()) ||- $options->get(self::OPTION_NO_STREAM) ||+ $options->get(SaveOption::NO_STREAM) ||$options->get(SaveOption::SILENT)) {return;@@ -107,7 +105,7 @@ class HookProcessorif ($entity->isNew() &&- empty($options[self::OPTION_NO_STREAM]) &&+ empty($options[SaveOption::NO_STREAM]) &&empty($options[SaveOption::SILENT]) &&$this->metadata->get(['scopes', $entity->getEntityType(), 'object'])) {@@ -172,7 +170,7 @@ class HookProcessorcontinue;}- if ($type === Entity::HAS_MANY) {+ if ($type === Entity::HAS_MANY || $type === Entity::MANY_MANY) {$this->handleCreateRelatedHasMany($entity, $relation, $notifiedEntityTypeList, $options);/** @noinspection PhpUnnecessaryStopStatementInspection */@@ -400,7 +398,7 @@ class HookProcessor$this->service->followEntityMass($entity, $userIdList);}- if (empty($options[self::OPTION_NO_STREAM]) && empty($options[SaveOption::SILENT])) {+ if (empty($options[SaveOption::NO_STREAM]) && empty($options[SaveOption::SILENT])) {$this->service->noteCreate($entity, $options);}@@ -438,7 +436,7 @@ class HookProcessor*/private function afterSaveStreamNotNew1(CoreEntity $entity, array $options): void{- if (!empty($options[self::OPTION_NO_STREAM]) || !empty($options[SaveOption::SILENT])) {+ if (!empty($options[SaveOption::NO_STREAM]) || !empty($options[SaveOption::SILENT])) {return;}@@ -605,7 +603,7 @@ class HookProcessor$foreignLink = $entity->getRelationParam($link, RelationParam::FOREIGN);if (- !empty($options[self::OPTION_NO_STREAM]) ||+ !empty($options[SaveOption::NO_STREAM]) ||!empty($options[SaveOption::SILENT]) ||!$this->metadata->get(['scopes', $entityType, 'object'])) {@@ -638,7 +636,7 @@ class HookProcessor$foreignLink = $entity->getRelationParam($link, RelationParam::FOREIGN);if (- !empty($options[self::OPTION_NO_STREAM]) ||+ !empty($options[SaveOption::NO_STREAM]) ||!empty($options[SaveOption::SILENT]) ||!$this->metadata->get(['scopes', $entityType, 'object'])) {@@ -672,7 +670,7 @@ class HookProcessorreturn;}- if (!empty($options[self::OPTION_NO_STREAM]) || !empty($options[SaveOption::SILENT])) {+ if (!empty($options[SaveOption::NO_STREAM]) || !empty($options[SaveOption::SILENT])) {return;}