EspoCRM – Open Source CRM Application
PHP calendarcontactscrmcrm-platformcrm-systemcustomer-portalcustomer-supportcustomizabledocumentsemail-marketingkanbanleadsopen-sourcephpplatformsales-automationsingle-page-applicationsupport
next number process field force
Yuriibf250069f482
diff --git a/application/Espo/Core/FieldProcessing/NextNumber/Processor.php b/application/Espo/Core/FieldProcessing/NextNumber/Processor.phpindex 6930b17b91..9882ec9ac5 100644--- a/application/Espo/Core/FieldProcessing/NextNumber/Processor.php+++ b/application/Espo/Core/FieldProcessing/NextNumber/Processor.php@@ -72,6 +72,10 @@ class Processorpublic function process(Entity $entity, SaveOptions $options): void{+ if (!$entity->isNew()) {+ return;+ }+$fieldList = $this->getFieldList($entity->getEntityType());foreach ($fieldList as $field) {@@ -82,6 +86,7 @@ class Processor/*** To be invoked in custom hooks. The default hook must be suppressed.* Useful when the number should change only if some conditions met.+ * Processes even a non-new entity.** @since 9.3.0* @noinspection PhpUnused@@ -98,19 +103,30 @@ class Processorthrow new RuntimeException("Not a 'number' field.");}- $this->processItem($entity, $field, $options->toAssoc());+ $this->processItem(+ entity: $entity,+ field: $field,+ options: $options->toAssoc(),+ force: true,+ );}/*** @param array<string, mixed> $options*/- private function processItem(Entity $entity, string $field, array $options, bool $populate = false): void- {+ private function processItem(+ Entity $entity,+ string $field,+ array $options,+ bool $populate = false,+ bool $force = false,+ ): void {+if (!empty($options[SaveOption::IMPORT]) && $entity->has($field)) {return;}- if (!$entity->isNew()) {+ if (!$entity->isNew() && !$force) {if ($entity->isAttributeChanged($field)) {$entity->set($field, $entity->getFetched($field));}