create save context on save
This commit is contained in:
@@ -29,6 +29,8 @@
|
||||
|
||||
namespace Espo\Core\ORM\Repository\Option;
|
||||
|
||||
use Espo\Core\Utils\Util;
|
||||
|
||||
/**
|
||||
* @since 9.1.0
|
||||
*/
|
||||
@@ -36,8 +38,22 @@ class SaveContext
|
||||
{
|
||||
public const NAME = 'context';
|
||||
|
||||
private string $id;
|
||||
private bool $linkUpdated = false;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->id = Util::generateId();
|
||||
}
|
||||
|
||||
/**
|
||||
* An action ID.
|
||||
*/
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->id;
|
||||
}
|
||||
|
||||
public function setLinkUpdated(): self
|
||||
{
|
||||
$this->linkUpdated = true;
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
|
||||
namespace Espo\ORM\Repository;
|
||||
|
||||
use Espo\Core\ORM\Repository\Option\SaveContext;
|
||||
use Espo\ORM\Defs\RelationDefs;
|
||||
use Espo\ORM\EntityCollection;
|
||||
use Espo\ORM\EntityManager;
|
||||
@@ -132,6 +133,10 @@ class RDBRepository implements Repository
|
||||
*/
|
||||
public function save(Entity $entity, array $options = []): void
|
||||
{
|
||||
if (!isset($options[SaveContext::NAME])) {
|
||||
$options[SaveContext::NAME] = new SaveContext();
|
||||
}
|
||||
|
||||
$this->processCheckEntity($entity);
|
||||
|
||||
if ($entity instanceof BaseEntity) {
|
||||
|
||||
Reference in New Issue
Block a user