type fixes
This commit is contained in:
@@ -67,7 +67,7 @@ class MassConvertCurrency implements MassAction
|
||||
|
||||
protected CurrencyConverter $currencyConverter;
|
||||
|
||||
private $user;
|
||||
private User $user;
|
||||
|
||||
public function __construct(
|
||||
QueryBuilder $queryBuilder,
|
||||
@@ -161,6 +161,9 @@ class MassConvertCurrency implements MassAction
|
||||
return Result::fromArray($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $fieldList
|
||||
*/
|
||||
protected function convertEntity(
|
||||
Entity $entity,
|
||||
array $fieldList,
|
||||
@@ -218,6 +221,9 @@ class MassConvertCurrency implements MassAction
|
||||
return CurrencyRates::fromArray($ratesArray);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function getFieldList(string $entityType, Data $data): array
|
||||
{
|
||||
$forbiddenFieldList = $this->acl->getScopeForbiddenFieldList($entityType, 'edit');
|
||||
|
||||
@@ -172,6 +172,9 @@ class MassUpdate implements MassAction
|
||||
return Result::fromArray($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $fieldToCopyList
|
||||
*/
|
||||
protected function prepareItemValueMap(
|
||||
string $entityType,
|
||||
stdClass $valueMap,
|
||||
@@ -264,6 +267,9 @@ class MassUpdate implements MassAction
|
||||
$valueMap->$idsAttribute = $copiedIds;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
protected function detectFieldToCopyList(string $entityType, stdClass $valueMap): array
|
||||
{
|
||||
$resultFieldList = [];
|
||||
|
||||
@@ -42,11 +42,11 @@ use Espo\Core\Binding\BindingContainerBuilder;
|
||||
|
||||
class MassActionFactory
|
||||
{
|
||||
private $metadata;
|
||||
private Metadata $metadata;
|
||||
|
||||
private $injectableFactory;
|
||||
private InjectableFactory $injectableFactory;
|
||||
|
||||
private $aclManager;
|
||||
private AclManager $aclManager;
|
||||
|
||||
public function __construct(Metadata $metadata, InjectableFactory $injectableFactory, AclManager $aclManager)
|
||||
{
|
||||
@@ -86,6 +86,11 @@ class MassActionFactory
|
||||
return $this->injectableFactory->createWithBinding($className, $bindingContainer);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array<string,mixed> $with
|
||||
* @deprecated
|
||||
* @todo Remove.
|
||||
*/
|
||||
public function createWith(string $action, string $entityType, array $with): MassAction
|
||||
{
|
||||
$className = $this->getClassName($action, $entityType);
|
||||
@@ -97,6 +102,9 @@ class MassActionFactory
|
||||
return $this->injectableFactory->createWith($className, $with);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
private function getClassName(string $action, string $entityType): ?string
|
||||
{
|
||||
$className = $this->getEntityTypeClassName($action, $entityType);
|
||||
@@ -110,6 +118,9 @@ class MassActionFactory
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ?class-string
|
||||
*/
|
||||
private function getEntityTypeClassName(string $action, string $entityType): ?string
|
||||
{
|
||||
return $this->metadata->get(
|
||||
|
||||
@@ -35,21 +35,26 @@ use RuntimeException;
|
||||
|
||||
class Params
|
||||
{
|
||||
private $entityType;
|
||||
private string $entityType;
|
||||
|
||||
private $ids;
|
||||
/**
|
||||
* @var ?string[]
|
||||
*/
|
||||
private $ids = null;
|
||||
|
||||
private $searchParams;
|
||||
private ?SearchParams $searchParams = null;
|
||||
|
||||
private function __construct()
|
||||
{
|
||||
}
|
||||
private function __construct() {}
|
||||
|
||||
public function getEntityType(): string
|
||||
{
|
||||
return $this->entityType;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public function getIds(): array
|
||||
{
|
||||
if (!$this->ids) {
|
||||
@@ -73,6 +78,9 @@ class Params
|
||||
return !is_null($this->ids);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string[] $ids
|
||||
*/
|
||||
public static function createWithIds(string $entityType, array $ids): self
|
||||
{
|
||||
return self::fromRaw([
|
||||
@@ -86,7 +94,6 @@ class Params
|
||||
$obj = new self();
|
||||
|
||||
$obj->entityType = $entityType;
|
||||
|
||||
$obj->searchParams = $searchParams;
|
||||
|
||||
return $obj;
|
||||
@@ -95,18 +102,28 @@ class Params
|
||||
/**
|
||||
* Create from raw params.
|
||||
*
|
||||
* @param array{
|
||||
* entityType?: string,
|
||||
* where?: array<int,array<string,mixed>>,
|
||||
* ids?: ?string[],
|
||||
* searchParams?: ?array<string,mixed>,
|
||||
* } $params
|
||||
* @throws RuntimeException
|
||||
*/
|
||||
public static function fromRaw(array $params, ?string $entityType = null): self
|
||||
{
|
||||
/** @var array<string,mixed> $params */
|
||||
|
||||
$obj = new self();
|
||||
|
||||
$obj->entityType = $entityType ?? $params['entityType'] ?? null;
|
||||
$passedEntityType = $entityType ?? $params['entityType'] ?? null;
|
||||
|
||||
if (!$obj->entityType) {
|
||||
if (!$passedEntityType) {
|
||||
throw new RuntimeException("No 'entityType'.");
|
||||
}
|
||||
|
||||
$obj->entityType = $passedEntityType;
|
||||
|
||||
$where = $params['where'] ?? null;
|
||||
$ids = $params['ids'] ?? null;
|
||||
|
||||
@@ -168,7 +185,11 @@ class Params
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
* @return array{
|
||||
* entityType: ?string,
|
||||
* ids: ?string[],
|
||||
* searchParams: string,
|
||||
* }
|
||||
*/
|
||||
public function __serialize(): array
|
||||
{
|
||||
@@ -179,6 +200,13 @@ class Params
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{
|
||||
* entityType: ?string,
|
||||
* ids: ?string[],
|
||||
* searchParams: string,
|
||||
* } $data
|
||||
*/
|
||||
public function __unserialize(array $data): void
|
||||
{
|
||||
$this->entityType = $data['entityType'];
|
||||
|
||||
@@ -33,11 +33,17 @@ use RuntimeException;
|
||||
|
||||
class Result
|
||||
{
|
||||
private ?int $count = null;
|
||||
|
||||
/**
|
||||
* @var ?string[]
|
||||
*/
|
||||
private $ids = null;
|
||||
|
||||
private $count = null;
|
||||
|
||||
public function __construct(int $count, ?array $ids = null)
|
||||
/**
|
||||
* @param ?string[] $ids
|
||||
*/
|
||||
public function __construct(?int $count, ?array $ids = null)
|
||||
{
|
||||
$this->count = $count;
|
||||
$this->ids = $ids;
|
||||
@@ -53,6 +59,9 @@ class Result
|
||||
return $this->count !== null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string[]
|
||||
*/
|
||||
public function getIds(): array
|
||||
{
|
||||
if (!$this->hasIds()) {
|
||||
@@ -78,6 +87,12 @@ class Result
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array{
|
||||
* count?: ?int,
|
||||
* ids?: ?string[],
|
||||
* } $data
|
||||
*/
|
||||
public static function fromArray(array $data): self
|
||||
{
|
||||
$obj = new self(
|
||||
|
||||
Reference in New Issue
Block a user