This commit is contained in:
Yuri Kuznetsov
2024-01-04 12:46:21 +02:00
parent a8c1bf0a2d
commit 2080ade438
2 changed files with 20 additions and 28 deletions
+7 -3
View File
@@ -29,7 +29,9 @@
namespace Espo\Tools\Kanban;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\FieldProcessing\ListLoadProcessor;
use Espo\Core\FieldProcessing\Loader\Params as FieldLoaderParams;
use Espo\Core\Record\Collection;
@@ -111,6 +113,8 @@ class Kanban
* Get kanban record data.
*
* @throws Error
* @throws Forbidden
* @throws BadRequest
*/
public function getResult(): Result
{
@@ -182,7 +186,7 @@ class Kanban
$newOrder = $itemQuery->getOrder();
array_unshift($newOrder, [
'COALESCE:(kanbanOrder.order, ' . strval($this->maxOrderNumber + 1) . ')',
'COALESCE:(kanbanOrder.order, ' . ($this->maxOrderNumber + 1) . ')',
'ASC',
]);
@@ -260,7 +264,7 @@ class Kanban
$statusField = $this->metadata->get(['scopes', $this->entityType, 'statusField']);
if (!$statusField) {
throw new Error("No status field for entity type '{$this->entityType}'.");
throw new Error("No status field for entity type '$this->entityType'.");
}
return $statusField;
@@ -279,7 +283,7 @@ class Kanban
$statusList = $this->metadata->get(['entityDefs', $this->entityType, 'fields', $statusField, 'options']);
if (empty($statusList)) {
throw new Error("No options for status field for entity type '{$this->entityType}'.");
throw new Error("No options for status field for entity type '$this->entityType'.");
}
return $statusList;
+13 -25
View File
@@ -31,43 +31,31 @@ namespace Espo\Tools\Kanban;
use Espo\Core\Acl\Table;
use Espo\Core\AclManager;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Exceptions\Error;
use Espo\Core\Exceptions\Forbidden;
use Espo\Core\Exceptions\ForbiddenSilent;
use Espo\Core\InjectableFactory;
use Espo\Core\Select\SearchParams;
use Espo\Core\Utils\Config;
use Espo\Core\Utils\Metadata;
use Espo\Entities\User;
class KanbanService
{
private User $user;
private AclManager $aclManager;
private InjectableFactory $injectableFactory;
private Config $config;
private Metadata $metadata;
private Orderer $orderer;
public function __construct(
User $user,
AclManager $aclManager,
InjectableFactory $injectableFactory,
Config $config,
Metadata $metadata,
Orderer $orderer
) {
$this->user = $user;
$this->aclManager = $aclManager;
$this->injectableFactory = $injectableFactory;
$this->config = $config;
$this->metadata = $metadata;
$this->orderer = $orderer;
}
private User $user,
private AclManager $aclManager,
private InjectableFactory $injectableFactory,
private Config $config,
private Metadata $metadata,
private Orderer $orderer
) {}
/**
* @throws Error
* @throws ForbiddenSilent
* @throws Forbidden
* @throws BadRequest
*/
public function getData(string $entityType, SearchParams $searchParams): Result
{
@@ -93,7 +81,7 @@ class KanbanService
/**
* @param string[] $ids
* @throws ForbiddenSilent
* @throws Forbidden
*/
public function order(string $entityType, string $group, array $ids): void
{
@@ -128,7 +116,7 @@ class KanbanService
}
if ($this->metadata->get(['recordDefs', $entityType, 'kanbanDisabled'])) {
throw new ForbiddenSilent("Kanban is disabled for '{$entityType}'.");
throw new ForbiddenSilent("Kanban is disabled for '$entityType'.");
}
if (!$this->aclManager->check($this->user, $entityType, Table::ACTION_READ)) {