This commit is contained in:
Yuri Kuznetsov
2023-02-17 17:44:29 +02:00
parent 4c265dbae1
commit cc828661da
7 changed files with 28 additions and 25 deletions

View File

@@ -492,7 +492,7 @@ class AfterFetch implements AfterFetchInterface
$attachmentRepository = $this->entityManager->getRepository(Attachment::ENTITY_TYPE);
foreach ($attachmentIdList as $attachmentId) {
$attachment = $attachmentRepository->get($attachmentId);
$attachment = $attachmentRepository->getById($attachmentId);
if (!$attachment) {
continue;

View File

@@ -211,10 +211,15 @@ class TargetList extends Record implements
}
}
/**
* @throws Forbidden
* @throws Error
* @throws NotFound
*/
public function unlinkAll(string $id, string $link): void
{
/** @var TargetListEntity|null $entity */
$entity = $this->getRepository()->get($id);
/** @var ?TargetListEntity $entity */
$entity = $this->getRepository()->getById($id);
if (!$entity) {
throw new NotFound();

View File

@@ -57,21 +57,15 @@ use PDO;
*/
class RDBRepository implements Repository
{
protected string $entityType;
protected EntityManager $entityManager;
protected EntityFactory $entityFactory;
protected HookMediator $hookMediator;
protected RDBTransactionManager $transactionManager;
public function __construct(
string $entityType,
EntityManager $entityManager,
EntityFactory $entityFactory,
protected string $entityType,
protected EntityManager $entityManager,
protected EntityFactory $entityFactory,
?HookMediator $hookMediator = null
) {
$this->entityType = $entityType;
$this->entityFactory = $entityFactory;
$this->entityManager = $entityManager;
$this->hookMediator = $hookMediator ?? (new EmptyHookMediator());
$this->transactionManager = new RDBTransactionManager($entityManager->getTransactionManager());
}
@@ -145,7 +139,7 @@ class RDBRepository implements Repository
/**
* @param TEntity $entity
* @param array<string,mixed> $options
* @param array<string, mixed> $options
*/
public function save(Entity $entity, array $options = []): void
{
@@ -881,7 +875,7 @@ class RDBRepository implements Repository
* * `where(array $clause)`
* * `where(string $key, string $value)`
*
* @param WhereItem|array<scalar,mixed>|string $clause A key or where clause.
* @param WhereItem|array<scalar, mixed>|string $clause A key or where clause.
* @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string.
* @return RDBSelectBuilder<TEntity>
*/
@@ -898,7 +892,7 @@ class RDBRepository implements Repository
* * `having(array $clause)`
* * `having(string $key, string $value)`
*
* @param WhereItem|array<scalar,mixed>|string $clause A key or where clause.
* @param WhereItem|array<scalar, mixed>|string $clause A key or where clause.
* @param mixed[]|scalar|null $value A value. Should be omitted if the first argument is not string.
* @return RDBSelectBuilder<TEntity>
*/

View File

@@ -53,16 +53,17 @@ use RuntimeException;
*/
class RDBSelectBuilder
{
private EntityManager $entityManager;
private SelectBuilder $builder;
/** @var RDBRepository<TEntity> */
private RDBRepository $repository;
private bool $returnSthCollection = false;
public function __construct(EntityManager $entityManager, string $entityType, ?Select $query = null)
{
$this->entityManager = $entityManager;
public function __construct(
private EntityManager $entityManager,
string $entityType,
?Select $query = null
) {
/** @var RDBRepository<TEntity> $repository */
$repository = $this->entityManager->getRepository($entityType);
@@ -90,7 +91,7 @@ class RDBSelectBuilder
}
/**
* @param ?array<string,mixed> $params @deprecated. Omit it.
* @param ?array<string, mixed> $params @deprecated. Omit it.
* @return Collection<TEntity>
*/
public function find(?array $params = null): Collection
@@ -129,7 +130,7 @@ class RDBSelectBuilder
/**
* Get a number of records.
*
* @param ?array<string,mixed> $params @deprecated
* @param ?array<string, mixed> $params @deprecated
*/
public function count(?array $params = null): int
{
@@ -416,6 +417,7 @@ class RDBSelectBuilder
/**
* For backward compatibility.
* @deprecated As of v6.0.
* @todo Remove.
* @param array<string, mixed> $params
*/

View File

@@ -115,8 +115,10 @@ class Email extends Database implements
return;
}
if ($entity->get('fromEmailAddressId')) {
$ea = $this->getEmailAddressRepository()->get($entity->get('fromEmailAddressId'));
$fromEmailAddressId = $entity->get('fromEmailAddressId');
if ($fromEmailAddressId) {
$ea = $this->getEmailAddressRepository()->getById($fromEmailAddressId);
if ($ea) {
$entity->set('from', $ea->get('name'));

View File

@@ -46,7 +46,7 @@ class ExternalAccount extends Database
if (!$entity) {
/** @var ExternalAccountEntity $entity */
$entity = $this->get();
$entity = $this->getNew();
$entity->set('id', $id);
}

View File

@@ -46,7 +46,7 @@ class Integration extends Database
if (!$entity) {
/** @var IntegrationEntity $entity */
$entity = $this->get();
$entity = $this->getNew();
$entity->set('id', $id);
}