Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions src/Bitrix24Accounts/Entity/Bitrix24Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,11 @@
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException;
use Bitrix24\SDK\Core\Response\DTO\RenewedAuthToken;
use Bitrix24\Lib\Bitrix24Accounts\Infrastructure\Doctrine\Bitrix24AccountRepository;
use Carbon\CarbonImmutable;
use Doctrine\ORM\Mapping\Embedded;
use Override;
use Symfony\Bridge\Doctrine\Types\UuidType;
use Symfony\Component\Serializer\Annotation\Ignore;
use Symfony\Component\Serializer\Annotation\SerializedName;
use Symfony\Component\Uid\Uuid;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Contracts\EventDispatcher\Event;

#[ORM\Entity(repositoryClass: Bitrix24AccountRepository::class)]
class Bitrix24Account implements Bitrix24AccountInterface, AggregateRootEventsEmitterInterface
{
private string $accessToken;
Expand All @@ -51,7 +44,7 @@

private ?string $comment = null;

private AuthToken $authToken;

Check failure on line 47 in src/Bitrix24Accounts/Entity/Bitrix24Account.php

View workflow job for this annotation

GitHub Actions / PHPStan (8.3, highest, ubuntu-latest)

Property Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account::$authToken is never read, only written.

/**
* @var Event[]
Expand All @@ -60,33 +53,16 @@


public function __construct(
#[ORM\Id]
#[ORM\Column(type: UuidType::NAME, unique: true)]
private Uuid $id,
#[ORM\Column(name: 'b24_user_id', type: 'integer', nullable: false)]
#[SerializedName('b24_user_id')]
private readonly int $bitrix24UserId,
#[ORM\Column(name: 'is_b24_user_admin', type: 'boolean', nullable: false)]
#[SerializedName('is_b24_user_admin')]
private readonly bool $isBitrix24UserAdmin,
/** bitrix24 portal unique id */
#[ORM\Column(name: 'member_id', type: 'string', nullable: false)]
#[SerializedName('member_id')]
private readonly string $memberId,
#[ORM\Column(name: 'domain_url', type: 'string', nullable: false)]
#[SerializedName('domain_url')]
private string $domainUrl,
#[ORM\Column(name: 'account_status', type: 'string', nullable: false, enumType: Bitrix24AccountStatus::class)]
private Bitrix24AccountStatus $status,
AuthToken $authToken,
#[ORM\Column(name: 'created_at_utc', type: 'carbon_immutable', precision: 3, nullable: false)]
#[Ignore]
private readonly CarbonImmutable $createdAt,
#[ORM\Column(name: 'update_at_utc', type: 'carbon_immutable', precision: 3, nullable: false)]
#[Ignore]
private CarbonImmutable $updatedAt,
#[ORM\Column(name: 'application_version', type: 'integer', nullable: false)]
#[Ignore]
private int $applicationVersion,
Scope $applicationScope,
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,7 @@ public function getById(Uuid $uuid): Bitrix24AccountInterface
#[Override]
public function save(Bitrix24AccountInterface $bitrix24Account): void
{

$this->getEntityManager()->persist($bitrix24Account);

//todo discuss add flush arg to contract or add flusher in usecases?
$this->getEntityManager()->flush();

}

/**
Expand All @@ -81,18 +76,15 @@ public function findByMemberId(string $memberId, ?Bitrix24AccountStatus $bitrix2
* @inheritdoc
*/
#[Override]
public function delete(Uuid $uuid, bool $flush = false): void
public function delete(Uuid $uuid): void
{
$bitrix24Account = $this->getEntityManager()->getRepository(Bitrix24Account::class)->find($uuid);

if ($bitrix24Account === null) {
throw new Bitrix24AccountNotFoundException(sprintf('bitrix24 account not found by id %s', $uuid->toRfc4122()));
}

$this->getEntityManager()->remove($bitrix24Account);

if ($flush) {
$this->getEntityManager()->flush();
}
}

public function findAllActive(): array
Expand Down
1 change: 1 addition & 0 deletions src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function handle(Command $command): void
}

$targetAccount = $accounts[0];

/**
* @var Bitrix24AccountInterface|AggregateRootEventsEmitterInterface $targetAccount
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
class HandlerTest extends TestCase
{
private Handler $handler;
private Flusher $flusher;
private Bitrix24AccountRepositoryInterface $repository;
private TraceableEventDispatcher $eventDispatcher;

Expand All @@ -62,6 +63,8 @@ public function testRenewAuthTokenWithoutBitrix24UserId(): void

$this->repository->save($bitrix24Account);

$this->flusher->flush();

$newAuthToken = new AuthToken('new_1', 'new_2', 3600);
$this->handler->handle(
new Command(
Expand Down
Loading