snapshot of https://github.com/espocrm/espocrm.git (master, 2026-09-18; blobs > 131072B omitted)
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 1s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s
Some checks failed
Test / Test on PHP 8.3 (push) Failing after 5s
Test / Test on PHP 8.4 (push) Failing after 4s
Test / Test on PHP 8.5 (push) Failing after 3s
TypeScript static analysis / TypeScript check (push) Failing after 14s
Test Integration on MySQL / Test on PHP 8.3 (push) Failing after 1s
Test Integration on MySQL / Test on PHP 8.5 (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 fix (push) Failing after 1s
Test Integration on PostgreSQL / Test on PHP 8.4 master (push) Failing after 1s
This commit is contained in:
42
application/Espo/ORM/Repository/Option/MassRelateOptions.php
Normal file
42
application/Espo/ORM/Repository/Option/MassRelateOptions.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Espo\ORM\Repository\Option\Traits\Options;
|
||||
|
||||
/**
|
||||
* Mass-relate options.
|
||||
*
|
||||
* Immutable.
|
||||
*/
|
||||
class MassRelateOptions
|
||||
{
|
||||
use Options;
|
||||
}
|
||||
42
application/Espo/ORM/Repository/Option/RelateOptions.php
Normal file
42
application/Espo/ORM/Repository/Option/RelateOptions.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Espo\ORM\Repository\Option\Traits\Options;
|
||||
|
||||
/**
|
||||
* Relate options.
|
||||
*
|
||||
* Immutable.
|
||||
*/
|
||||
class RelateOptions
|
||||
{
|
||||
use Options;
|
||||
}
|
||||
42
application/Espo/ORM/Repository/Option/RemoveOptions.php
Normal file
42
application/Espo/ORM/Repository/Option/RemoveOptions.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Espo\ORM\Repository\Option\Traits\Options;
|
||||
|
||||
/**
|
||||
* Remove options.
|
||||
*
|
||||
* Immutable.
|
||||
*/
|
||||
class RemoveOptions
|
||||
{
|
||||
use Options;
|
||||
}
|
||||
189
application/Espo/ORM/Repository/Option/SaveContext.php
Normal file
189
application/Espo/ORM/Repository/Option/SaveContext.php
Normal file
@@ -0,0 +1,189 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Closure;
|
||||
use Espo\Core\Utils\Util;
|
||||
use LogicException;
|
||||
|
||||
/**
|
||||
* A save context.
|
||||
*
|
||||
* If a save invokes another save, the context instance should not be re-used.
|
||||
* If a save invokes a relate action, the context can be passed to that action.
|
||||
*
|
||||
* @since 10.0.0
|
||||
*
|
||||
* Before v10.0.0, since 9.1.0 it was located in the `Core` namespace.
|
||||
*/
|
||||
class SaveContext
|
||||
{
|
||||
public const NAME = 'context';
|
||||
|
||||
private string $actionId;
|
||||
private bool $linkUpdated = false;
|
||||
private ?bool $isNew = null;
|
||||
|
||||
/** @var Closure[] */
|
||||
private array $deferredActions = [];
|
||||
|
||||
/**
|
||||
* @param ?string $actionId An action ID.
|
||||
*/
|
||||
public function __construct(
|
||||
?string $actionId = null,
|
||||
) {
|
||||
$this->actionId = $actionId ?? Util::generateId();
|
||||
}
|
||||
|
||||
/**
|
||||
* An action ID. Used to group notifications. If a save invokes another save, the same ID can be re-used,
|
||||
* but the context instance should not be re-used. Create a derived context for this.
|
||||
*
|
||||
* @since 9.2.0
|
||||
*/
|
||||
public function getActionId(): string
|
||||
{
|
||||
return $this->actionId;
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Since v9.2.0. Use `getActionId`.
|
||||
*/
|
||||
public function getId(): string
|
||||
{
|
||||
return $this->getActionId();
|
||||
}
|
||||
|
||||
public function setLinkUpdated(): self
|
||||
{
|
||||
$this->linkUpdated = true;
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function isLinkUpdated(): bool
|
||||
{
|
||||
return $this->linkUpdated;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain from save options.
|
||||
*
|
||||
* @return ?self
|
||||
* @since 9.2.0.
|
||||
*/
|
||||
public static function obtainFromOptions(SaveOptions $options): ?self
|
||||
{
|
||||
$saveContext = $options->get(self::NAME);
|
||||
|
||||
if (!$saveContext instanceof self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $saveContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Obtain from raw save options.
|
||||
*
|
||||
* @param array<string, mixed> $options
|
||||
* @return ?self
|
||||
* @since 9.2.0.
|
||||
*/
|
||||
public static function obtainFromRawOptions(array $options): ?self
|
||||
{
|
||||
$saveContext = $options[self::NAME] ?? null;
|
||||
|
||||
if (!$saveContext instanceof self) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return $saveContext;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a deferred action.
|
||||
*
|
||||
* @param Closure $callback A callback.
|
||||
* @since 9.2.0.
|
||||
*/
|
||||
public function addDeferredAction(Closure $callback): void
|
||||
{
|
||||
$this->deferredActions[] = $callback;
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @since 9.2.0.
|
||||
*/
|
||||
public function callDeferredActions(): void
|
||||
{
|
||||
foreach ($this->deferredActions as $callback) {
|
||||
$callback();
|
||||
}
|
||||
|
||||
$this->deferredActions = [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a derived context. To be used for nested saves.
|
||||
*
|
||||
* @since 9.2.0
|
||||
*/
|
||||
public function createDerived(): self
|
||||
{
|
||||
return new self($this->actionId);
|
||||
}
|
||||
|
||||
/**
|
||||
* @internal
|
||||
* @since 10.0.0
|
||||
*/
|
||||
public function setIsNew(bool $isNew): void
|
||||
{
|
||||
if ($this->isNew !== null) {
|
||||
throw new LogicException("Cannot set already set isNew.");
|
||||
}
|
||||
|
||||
$this->isNew = $isNew;
|
||||
}
|
||||
|
||||
/**
|
||||
* Was the entity new before save. Can be accessed only after save is started.
|
||||
* To be used for late hooks, when then entity is already not new, to check.
|
||||
*
|
||||
* @since 10.0.0
|
||||
*/
|
||||
public function isNew(): bool
|
||||
{
|
||||
return $this->isNew ?? throw new LogicException("Cannot access isNew before it's set.");
|
||||
}
|
||||
}
|
||||
38
application/Espo/ORM/Repository/Option/SaveOption.php
Normal file
38
application/Espo/ORM/Repository/Option/SaveOption.php
Normal file
@@ -0,0 +1,38 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
class SaveOption
|
||||
{
|
||||
public const SKIP_ALL = 'skipAll';
|
||||
public const KEEP_NEW = 'keepNew';
|
||||
public const KEEP_DIRTY = 'keepDirty';
|
||||
public const KEEP_RELATIONS = 'keepRelations';
|
||||
}
|
||||
58
application/Espo/ORM/Repository/Option/SaveOptions.php
Normal file
58
application/Espo/ORM/Repository/Option/SaveOptions.php
Normal file
@@ -0,0 +1,58 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Espo\ORM\Repository\Option\SaveContext;
|
||||
use Espo\ORM\Repository\Option\Traits\Options;
|
||||
use UnexpectedValueException;
|
||||
|
||||
/**
|
||||
* Save options.
|
||||
*
|
||||
* Immutable.
|
||||
*/
|
||||
class SaveOptions
|
||||
{
|
||||
use Options;
|
||||
|
||||
/**
|
||||
* @since 10.0.0
|
||||
*/
|
||||
public function getContext(): SaveContext
|
||||
{
|
||||
$context = $this->get(SaveContext::NAME);
|
||||
|
||||
if (!$context instanceof SaveContext) {
|
||||
throw new UnexpectedValueException("No or bad 'context'.");
|
||||
}
|
||||
|
||||
return $context;
|
||||
}
|
||||
}
|
||||
100
application/Espo/ORM/Repository/Option/Traits/Options.php
Normal file
100
application/Espo/ORM/Repository/Option/Traits/Options.php
Normal file
@@ -0,0 +1,100 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option\Traits;
|
||||
|
||||
trait Options
|
||||
{
|
||||
/** @var array<string, mixed> */
|
||||
private array $options;
|
||||
|
||||
/**
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
private function __construct(array $options)
|
||||
{
|
||||
$this->options = $options;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create from an associative array.
|
||||
*
|
||||
* @param array<string, mixed> $options
|
||||
*/
|
||||
public static function fromAssoc(array $options): self
|
||||
{
|
||||
return new self($options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get an option value. Returns `null` if not set.
|
||||
*/
|
||||
public function get(string $option): mixed
|
||||
{
|
||||
return $this->options[$option] ?? null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether an option is set.
|
||||
*/
|
||||
public function has(string $option): bool
|
||||
{
|
||||
return array_key_exists($option, $this->options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone with an option value.
|
||||
*/
|
||||
public function with(string $option, mixed $value): self
|
||||
{
|
||||
$obj = clone $this;
|
||||
$obj->options[$option] = $value;
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* Clone with an option removed.
|
||||
*/
|
||||
public function without(string $option): self
|
||||
{
|
||||
$obj = clone $this;
|
||||
unset($obj->options[$option]);
|
||||
|
||||
return $obj;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array<string, mixed>
|
||||
*/
|
||||
public function toAssoc(): array
|
||||
{
|
||||
return $this->options;
|
||||
}
|
||||
}
|
||||
42
application/Espo/ORM/Repository/Option/UnrelateOptions.php
Normal file
42
application/Espo/ORM/Repository/Option/UnrelateOptions.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
/************************************************************************
|
||||
* This file is part of EspoCRM.
|
||||
*
|
||||
* EspoCRM – Open Source CRM application.
|
||||
* Copyright (C) 2014-2026 EspoCRM, Inc.
|
||||
* Website: https://www.espocrm.com
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*
|
||||
* The interactive user interfaces in modified source and object code versions
|
||||
* of this program must display Appropriate Legal Notices, as required under
|
||||
* Section 5 of the GNU Affero General Public License version 3.
|
||||
*
|
||||
* In accordance with Section 7(b) of the GNU Affero General Public License version 3,
|
||||
* these Appropriate Legal Notices must retain the display of the "EspoCRM" word.
|
||||
************************************************************************/
|
||||
|
||||
namespace Espo\ORM\Repository\Option;
|
||||
|
||||
use Espo\ORM\Repository\Option\Traits\Options;
|
||||
|
||||
/**
|
||||
* Unrelate options.
|
||||
*
|
||||
* Immutable.
|
||||
*/
|
||||
class UnrelateOptions
|
||||
{
|
||||
use Options;
|
||||
}
|
||||
Reference in New Issue
Block a user