Initial commit

This commit is contained in:
root
2026-01-19 17:44:46 +01:00
commit 823af8b11d
8721 changed files with 1130846 additions and 0 deletions

View File

@@ -0,0 +1,71 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban\Api;
use Espo\Core\Api\Action as ActionAlias;
use Espo\Core\Api\Request;
use Espo\Core\Api\Response;
use Espo\Core\Api\ResponseComposer;
use Espo\Core\Exceptions\BadRequest;
use Espo\Core\Record\SearchParamsFetcher;
use Espo\Tools\Kanban\KanbanService;
class GetData implements ActionAlias
{
public function __construct(
private KanbanService $service,
private SearchParamsFetcher $searchParamsFetcher
) {}
public function process(Request $request): Response
{
$entityType = $request->getRouteParam('entityType');
if (!$entityType) {
throw new BadRequest();
}
$searchParams = $this->searchParamsFetcher->fetch($request);
$result = $this->service->getData($entityType, $searchParams);
$list = [];
foreach ($result->getGroups() as $group) {
$list = [...$list, ...$group->collection->getValueMapList()];
}
return ResponseComposer::json([
'total' => $result->getTotal(),
'groups' => array_map(fn ($it) => $it->toRaw(), $result->getGroups()),
'list' => $list,
]);
}
}

View File

@@ -0,0 +1,68 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban\Api;
use Espo\Core\Api\Action;
use Espo\Core\Api\Request;
use Espo\Core\Api\Response;
use Espo\Core\Api\ResponseComposer;
use Espo\Core\Exceptions\BadRequest;
use Espo\Tools\Kanban\KanbanService;
class PutOrder implements Action
{
public function __construct(private KanbanService $service)
{}
public function process(Request $request): Response
{
$data = $request->getParsedBody();
$entityType = $data->entityType ?? null;
$group = $data->group ?? null;
$ids = $data->ids ?? null;
if (empty($entityType) || !is_string($entityType)) {
throw new BadRequest();
}
if (empty($group) || !is_string($group)) {
throw new BadRequest();
}
if (!is_array($ids)) {
throw new BadRequest();
}
$this->service->order($entityType, $group, $ids);
return ResponseComposer::json(true);
}
}

View File

@@ -0,0 +1,58 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban;
use Espo\Core\Record\Collection;
use Espo\ORM\Entity;
use stdClass;
class GroupItem
{
/**
* @param Collection<Entity> $collection
*/
public function __construct(
readonly public string $name,
readonly public Collection $collection,
readonly public ?string $label = null,
readonly public ?string $style = null,
) {}
public function toRaw(): stdClass
{
return (object) [
'name' => $this->name,
'total' => $this->collection->getTotal(),
'list' => $this->collection->getValueMapList(),
'label' => $this->label,
'style' => $this->style,
];
}
}

View File

@@ -0,0 +1,294 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\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;
use Espo\Core\Record\Select\ApplierClassNameListProvider;
use Espo\Core\Record\ServiceContainer as RecordServiceContainer;
use Espo\Core\Select\SearchParams;
use Espo\Core\Select\SelectBuilderFactory;
use Espo\Core\Utils\Metadata;
use Espo\ORM\Entity;
use Espo\ORM\EntityManager;
class Kanban
{
private const DEFAULT_MAX_ORDER_NUMBER = 50;
private const MAX_GROUP_LENGTH = 100;
private ?string $entityType = null;
private bool $countDisabled = false;
private bool $orderDisabled = false;
private ?SearchParams $searchParams = null;
private ?string $userId = null;
private int $maxOrderNumber = self::DEFAULT_MAX_ORDER_NUMBER;
public function __construct(
private Metadata $metadata,
private SelectBuilderFactory $selectBuilderFactory,
private EntityManager $entityManager,
private ListLoadProcessor $listLoadProcessor,
private RecordServiceContainer $recordServiceContainer,
private ApplierClassNameListProvider $applierClassNameListProvider,
) {}
public function setEntityType(string $entityType): self
{
$this->entityType = $entityType;
return $this;
}
public function setSearchParams(SearchParams $searchParams): self
{
$this->searchParams = $searchParams;
return $this;
}
public function setCountDisabled(bool $countDisabled): self
{
$this->countDisabled = $countDisabled;
return $this;
}
public function setOrderDisabled(bool $orderDisabled): self
{
$this->orderDisabled = $orderDisabled;
return $this;
}
public function setUserId(string $userId): self
{
$this->userId = $userId;
return $this;
}
public function setMaxOrderNumber(?int $maxOrderNumber): self
{
if ($maxOrderNumber === null) {
$this->maxOrderNumber = self::DEFAULT_MAX_ORDER_NUMBER;
return $this;
}
$this->maxOrderNumber = $maxOrderNumber;
return $this;
}
/**
* Get kanban record data.
*
* @throws Error
* @throws Forbidden
* @throws BadRequest
*/
public function getResult(): Result
{
if (!$this->entityType) {
throw new Error("Entity type is not specified.");
}
if (!$this->searchParams) {
throw new Error("No search params.");
}
$searchParams = $this->searchParams;
$recordService = $this->recordServiceContainer->get($this->entityType);
$maxSize = $searchParams->getMaxSize();
if ($this->countDisabled && $maxSize) {
$searchParams = $searchParams->withMaxSize($maxSize + 1);
}
$query = $this->selectBuilderFactory
->create()
->from($this->entityType)
->withStrictAccessControl()
->withSearchParams($searchParams)
->withAdditionalApplierClassNameList(
$this->applierClassNameListProvider->get($this->entityType)
)
->build();
$statusField = $this->getStatusField();
$statusList = $this->getStatusList();
$statusIgnoreList = $this->getStatusIgnoreList();
$groupList = [];
$repository = $this->entityManager->getRDBRepository($this->entityType);
$hasMore = false;
foreach ($statusList as $status) {
if (in_array($status, $statusIgnoreList)) {
continue;
}
if (!$status) {
continue;
}
$itemSelectBuilder = $this->entityManager
->getQueryBuilder()
->select()
->clone($query);
$itemSelectBuilder->where([
$statusField => $status,
]);
$itemQuery = $itemSelectBuilder->build();
$newOrder = $itemQuery->getOrder();
array_unshift($newOrder, [
'COALESCE:(kanbanOrder.order, ' . ($this->maxOrderNumber + 1) . ')',
'ASC',
]);
if ($this->userId && !$this->orderDisabled) {
$group = mb_substr($status, 0, self::MAX_GROUP_LENGTH);
$itemQuery = $this->entityManager
->getQueryBuilder()
->select()
->clone($itemQuery)
->order($newOrder)
->leftJoin(
'KanbanOrder',
'kanbanOrder',
[
'kanbanOrder.entityType' => $this->entityType,
'kanbanOrder.entityId:' => 'id',
'kanbanOrder.group' => $group,
'kanbanOrder.userId' => $this->userId,
]
)
->build();
}
$collectionSub = $repository
->clone($itemQuery)
->find();
if (!$this->countDisabled) {
$totalSub = $repository->clone($itemQuery)->count();
} else {
$recordCollection = Collection::createNoCount($collectionSub, $maxSize);
$collectionSub = $recordCollection->getCollection();
$totalSub = $recordCollection->getTotal();
if ($totalSub === Collection::TOTAL_HAS_MORE) {
$hasMore = true;
}
}
$loadProcessorParams = FieldLoaderParams
::create()
->withSelect($searchParams->getSelect());
foreach ($collectionSub as $e) {
$this->listLoadProcessor->process($e, $loadProcessorParams);
$recordService->prepareEntityForOutput($e);
}
/** @var Collection<Entity> $itemRecordCollection */
$itemRecordCollection = new Collection($collectionSub, $totalSub);
$groupList[] = new GroupItem($status, $itemRecordCollection);
}
$total = !$this->countDisabled ?
$repository->clone($query)->count() :
($hasMore ? Collection::TOTAL_HAS_MORE : Collection::TOTAL_HAS_NO_MORE);
return new Result($groupList, $total);
}
/**
* @throws Error
*/
private function getStatusField(): string
{
assert(is_string($this->entityType));
$statusField = $this->metadata->get(['scopes', $this->entityType, 'statusField']);
if (!$statusField) {
throw new Error("No status field for entity type '$this->entityType'.");
}
return $statusField;
}
/**
* @return string[]
* @throws Error
*/
private function getStatusList(): array
{
assert(is_string($this->entityType));
$statusField = $this->getStatusField();
$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'.");
}
return $statusList;
}
/**
* @return string[]
*/
private function getStatusIgnoreList(): array
{
assert(is_string($this->entityType));
return $this->metadata->get(['scopes', $this->entityType, 'kanbanStatusIgnoreList'], []);
}
}

View File

@@ -0,0 +1,126 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\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
{
public function __construct(
private User $user,
private AclManager $aclManager,
private InjectableFactory $injectableFactory,
private Config $config,
private Metadata $metadata,
private Orderer $orderer
) {}
/**
* @throws Error
* @throws Forbidden
* @throws BadRequest
*/
public function getData(string $entityType, SearchParams $searchParams): Result
{
$this->processAccessCheck($entityType);
$disableCount = $this->metadata
->get(['entityDefs', $entityType, 'collection', 'countDisabled']) ?? false;
$orderDisabled = $this->metadata
->get(['scopes', $entityType, 'kanbanOrderDisabled']) ?? false;
$maxOrderNumber = $this->config->get('kanbanMaxOrderNumber');
return $this->createKanban()
->setEntityType($entityType)
->setSearchParams($searchParams)
->setCountDisabled($disableCount)
->setOrderDisabled($orderDisabled)
->setUserId($this->user->getId())
->setMaxOrderNumber($maxOrderNumber)
->getResult();
}
/**
* @param string[] $ids
* @throws Forbidden
*/
public function order(string $entityType, string $group, array $ids): void
{
$this->processAccessCheck($entityType);
if ($this->user->isPortal()) {
throw new ForbiddenSilent("Kanban order is not allowed for portal users.");
}
$maxOrderNumber = $this->config->get('kanbanMaxOrderNumber');
$this->orderer
->setEntityType($entityType)
->setGroup($group)
->setUserId($this->user->getId())
->setMaxNumber($maxOrderNumber)
->order($ids);
}
private function createKanban(): Kanban
{
return $this->injectableFactory->create(Kanban::class);
}
/**
* @throws ForbiddenSilent
*/
private function processAccessCheck(string $entityType): void
{
if (!$this->metadata->get(['scopes', $entityType, 'object'])) {
throw new ForbiddenSilent("Non-object entities are not supported.");
}
if ($this->metadata->get(['recordDefs', $entityType, 'kanbanDisabled'])) {
throw new ForbiddenSilent("Kanban is disabled for '$entityType'.");
}
if (!$this->aclManager->check($this->user, $entityType, Table::ACTION_READ)) {
throw new ForbiddenSilent();
}
}
}

View File

@@ -0,0 +1,72 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Utils\Id\RecordIdGenerator;
use Espo\Core\Utils\Metadata;
class Orderer
{
public function __construct(
private EntityManager $entityManager,
private Metadata $metadata,
private RecordIdGenerator $idGenerator
) {}
public function setEntityType(string $entityType): OrdererProcessor
{
return $this->createProcessor()->setEntityType($entityType);
}
public function setGroup(string $group): OrdererProcessor
{
return $this->createProcessor()->setGroup($group);
}
public function setUserId(string $userId): OrdererProcessor
{
return $this->createProcessor()->setUserId($userId);
}
public function setMaxNumber(?int $maxNumber): OrdererProcessor
{
return $this->createProcessor()->setMaxNumber($maxNumber);
}
public function createProcessor(): OrdererProcessor
{
return new OrdererProcessor(
$this->entityManager,
$this->metadata,
$this->idGenerator
);
}
}

View File

@@ -0,0 +1,234 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban;
use Espo\Core\Utils\Id\RecordIdGenerator;
use Espo\Entities\KanbanOrder;
use Espo\Core\ORM\EntityManager;
use Espo\Core\Utils\Metadata;
use Espo\ORM\Name\Attribute;
use LogicException;
class OrdererProcessor
{
private const MAX_GROUP_LENGTH = 100;
private const DEFAULT_MAX_NUMBER = 50;
private ?string $entityType = null;
private ?string $group = null;
private ?string $userId = null;
private int $maxNumber = self::DEFAULT_MAX_NUMBER;
public function __construct(
private EntityManager $entityManager,
private Metadata $metadata,
private RecordIdGenerator $idGenerator
) {}
public function setEntityType(string $entityType): self
{
$this->entityType = $entityType;
return $this;
}
public function setGroup(string $group): self
{
$this->group = mb_substr($group, 0, self::MAX_GROUP_LENGTH);
return $this;
}
public function setUserId(string $userId): self
{
$this->userId = $userId;
return $this;
}
public function setMaxNumber(?int $maxNumber): self
{
if ($maxNumber === null) {
$this->maxNumber = self::DEFAULT_MAX_NUMBER;
return $this;
}
$this->maxNumber = $maxNumber;
return $this;
}
/**
* @param string[] $ids
*/
public function order(array $ids): void
{
$this->validate();
$count = count($ids);
if (!$count) {
return;
}
$this->entityManager
->getTransactionManager()
->start();
$deleteQuery1 = $this->entityManager
->getQueryBuilder()
->delete()
->from(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'userId' => $this->userId,
'entityId' => $ids,
])
->build();
$this->entityManager->getQueryExecutor()->execute($deleteQuery1);
$minOrder = null;
$first = $this->entityManager
->getRDBRepository(KanbanOrder::ENTITY_TYPE)
->select([Attribute::ID, 'order'])
->where([
'entityType' => $this->entityType,
'userId' => $this->userId,
'group' => $this->group,
])
->order('order')
->findOne();
if ($first) {
$minOrder = $first->get('order');
}
if ($minOrder !== null) {
$offset = $count - $minOrder;
$updateQuery = $this->entityManager
->getQueryBuilder()
->update()
->in(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'group' => $this->group,
'userId' => $this->userId,
])
->set([
'order:' => 'ADD:(order, ' . strval($offset) . ')'
])
->build();
$this->entityManager->getQueryExecutor()->execute($updateQuery);
}
$collection = $this->entityManager
->getCollectionFactory()
->create(KanbanOrder::ENTITY_TYPE);
foreach ($ids as $i => $id) {
$item = $this->entityManager->getNewEntity(KanbanOrder::ENTITY_TYPE);
$item->set([
'id' => $this->idGenerator->generate(),
'entityId' => $id,
'entityType' => $this->entityType,
'group' => $this->group,
'userId' => $this->userId,
'order' => $i,
]);
$collection[] = $item;
}
$this->entityManager->getMapper()->massInsert($collection);
$deleteQuery2 = $this->entityManager
->getQueryBuilder()
->delete()
->from(KanbanOrder::ENTITY_TYPE)
->where([
'entityType' => $this->entityType,
'group' => $this->group,
'userId' => $this->userId,
'order>' => $this->maxNumber,
])
->build();
$this->entityManager->getQueryExecutor()->execute($deleteQuery2);
$this->entityManager
->getTransactionManager()
->commit();
}
private function validate(): void
{
if (! $this->entityType) {
throw new LogicException("No entity type.");
}
if (! $this->group) {
throw new LogicException("No group.");
}
if (! $this->userId) {
throw new LogicException("No user ID.");
}
if (! $this->metadata->get(['scopes', $this->entityType, 'object'])) {
throw new LogicException("Not allowed entity type.");
}
$orderDisabled = $this->metadata->get(['scopes', $this->entityType, 'kanbanOrderDisabled']);
if ($orderDisabled) {
throw new LogicException("Order is disabled.");
}
$statusField = $this->metadata->get(['scopes', $this->entityType, 'statusField']);
if (! $statusField) {
throw new LogicException("Not status field.");
}
$statusList = $this->metadata
->get(['entityDefs', $this->entityType, 'fields', $statusField, 'options']) ?? [];
if (!in_array($this->group, $statusList)) {
throw new LogicException("Group is not available in status list.");
}
}
}

View File

@@ -0,0 +1,54 @@
<?php
/************************************************************************
* This file is part of EspoCRM.
*
* EspoCRM Open Source CRM application.
* Copyright (C) 2014-2025 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\Tools\Kanban;
class Result
{
/**
* @param GroupItem[] $groups,
*/
public function __construct(
private array $groups,
private int $total,
) {}
/**
* @return GroupItem[]
*/
public function getGroups(): array
{
return $this->groups;
}
public function getTotal(): int
{
return $this->total;
}
}