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
3 changes: 1 addition & 2 deletions bin/doctrine
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
#!/usr/bin/env php
<?php

use Bitrix24\SDK\Lib\Tests\EntityManagerFactory;
use Bitrix24\Lib\Tests\EntityManagerFactory;
use Doctrine\ORM\Tools\Console\ConsoleRunner;
use Doctrine\ORM\Tools\Console\EntityManagerProvider\SingleManagerProvider;

require_once 'tests/bootstrap.php';

ConsoleRunner::run(
new SingleManagerProvider(EntityManagerFactory::get()),
[]
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,12 @@
},
"autoload": {
"psr-4": {
"Bitrix24\\SDK\\Lib\\": "src"
"Bitrix24\\Lib\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Bitrix24\\SDK\\Lib\\Tests\\": "tests",
"Bitrix24\\Lib\\Tests\\": "tests",
"Bitrix24\\SDK\\Tests\\": "vendor/bitrix24/b24phpsdk/tests"
}
}
Expand Down
42 changes: 0 additions & 42 deletions config/doctrine/xml/Bitrix24Account.dcm.xml

This file was deleted.

13 changes: 0 additions & 13 deletions config/doctrine/xml/TestUser.dcm.xml

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xs="https://www.w3.org/2001/XMLSchema"
xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account" table="bitrix24account">
<id name="id" type="uuid" column="id">
<generator strategy="CUSTOM"/>
<custom-id-generator class="Symfony\Bridge\Doctrine\IdGenerator\UuidGenerator"/>
</id>

<field name="bitrix24UserId" type="integer" column="b24_user_id" nullable="false"/>
<field name="isBitrix24UserAdmin" type="boolean" column="is_b24_user_admin" nullable="false"/>

<field name="memberId" type="string" column="member_id" nullable="false"/>

<field name="domainUrl" type="string" column="domain_url" nullable="false"/>

<field name="accountStatus" type="string" column="account_status" nullable="false"/>

<embedded name="authToken" class="Bitrix24\SDK\Core\Credentials\AuthToken"/>

<field name="createdAt" type="datetime_immutable" column="created_at_utc" precision="3" nullable="false"/>

<field name="updatedAt" type="datetime_immutable" column="update_at_utc" precision="3" nullable="false"/>

<field name="applicationVersion" type="integer" column="application_version" nullable="false"/>

<!-- Вложенный объект Scope -->

</entity>
</doctrine-mapping>
12 changes: 12 additions & 0 deletions config/xml/Bitrix24.Lib.Bitrix24Accounts.Entity.TestUser.dcm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xs="https://www.w3.org/2001/XMLSchema"
xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<entity name="Bitrix24\Lib\Bitrix24Accounts\Entity\TestUser" table="test_user">
<id name="id" type="integer" column="id">
<generator strategy="AUTO"/>
</id>

<field name="login" type="string" nullable="false"/>
<field name="password" type="string" nullable="false"/>
</entity>
</doctrine-mapping>
10 changes: 10 additions & 0 deletions config/xml/Bitrix24.SDK.Core.Credentials.AuthToken.dcm.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<doctrine-mapping xmlns="http://doctrine-project.org/schemas/orm/doctrine-mapping"
xmlns:xs="https://www.w3.org/2001/XMLSchema"
xmlns:orm="https://www.doctrine-project.org/schemas/orm/doctrine-mapping.xsd">
<embeddable name="Bitrix24\SDK\Core\Credentials\AuthToken" read-only="true">
<field name="accessToken" type="string" column="access_token"/>
<field name="refreshToken" type="string" column="refresh_token"/>
<field name="expires" type="integer" column="expires"/>
<field name="expiresIn" type="integer" column="expires_in"/>
</embeddable>
</doctrine-mapping>
10 changes: 7 additions & 3 deletions src/Bitrix24Accounts/Entity/Bitrix24Account.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\Entity;
namespace Bitrix24\Lib\Bitrix24Accounts\Entity;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
Expand All @@ -25,8 +25,9 @@
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use Bitrix24\SDK\Core\Exceptions\UnknownScopeCodeException;
use Bitrix24\SDK\Core\Response\DTO\RenewedAuthToken;
use Bitrix24\SDK\Lib\Bitrix24Accounts\Infrastructure\Doctrine\Bitrix24AccountRepository;
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;
Expand All @@ -50,6 +51,8 @@

private ?string $comment = null;

private AuthToken $authToken;

Check failure on line 54 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 @@ -74,7 +77,7 @@
private string $domainUrl,
#[ORM\Column(name: 'account_status', type: 'string', nullable: false, enumType: Bitrix24AccountStatus::class)]
private Bitrix24AccountStatus $accountStatus,
AuthToken $authToken,
AuthToken $authToken,
#[ORM\Column(name: 'created_at_utc', type: 'carbon_immutable', precision: 3, nullable: false)]
#[Ignore]
private readonly CarbonImmutable $createdAt,
Expand All @@ -87,6 +90,7 @@
Scope $applicationScope,
)
{
$this->authToken = $authToken;
$this->accessToken = $authToken->accessToken;
$this->refreshToken = $authToken->refreshToken;
$this->expires = $authToken->expires;
Expand Down
3 changes: 2 additions & 1 deletion src/Bitrix24Accounts/Entity/TestUser.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\Entity;
namespace Bitrix24\Lib\Bitrix24Accounts\Entity;

class TestUser
{
Expand Down Expand Up @@ -30,6 +30,7 @@ public function setPassword(string $password): void
{
$this->password = $password;
}

public function getId(): int
{
return $this->id;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\Exceptions;
namespace Bitrix24\Lib\Bitrix24Accounts\Exceptions;

use DomainException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,31 +2,28 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\Infrastructure\Doctrine;
namespace Bitrix24\Lib\Bitrix24Accounts\Infrastructure\Doctrine;

use Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account;
use Bitrix24\Lib\Bitrix24Accounts\UseCase\SaveAccount\Handler;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Exceptions\Bitrix24AccountNotFoundException;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;
use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface;
use Bitrix24\SDK\Core\Exceptions\InvalidArgumentException;
use Bitrix24\SDK\Lib\Bitrix24Accounts\Entity\Bitrix24Account;
use Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\Command\Flusher;
use Doctrine\ORM\EntityManagerInterface;
use Doctrine\ORM\EntityRepository;
use Override;
use Symfony\Component\Uid\Uuid;

class Bitrix24AccountRepository extends EntityRepository implements Bitrix24AccountRepositoryInterface
{
private Flusher $flusher;
public function __construct(
EntityManagerInterface $entityManager,
Flusher $flusher
EntityManagerInterface $entityManager
)
{
parent::__construct($entityManager, $entityManager->getClassMetadata(Bitrix24Account::class));
$this->flusher = $flusher;
}

/**
Expand All @@ -51,9 +48,9 @@ public function getById(Uuid $uuid): Bitrix24AccountInterface
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();
$this->flusher->flush();
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/ReadModel/Fetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\ReadModel;
namespace Bitrix24\Lib\Bitrix24Accounts\ReadModel;

use Doctrine\ORM\EntityManagerInterface;
use Knp\Component\Pager\Pagination\PaginationInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\ChangeDomainUrl;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\ChangeDomainUrl;

readonly class Command
{
Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/UseCase/ChangeDomainUrl/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\ChangeDomainUrl;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\ChangeDomainUrl;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/UseCase/InstallFinish/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\InstallFinish;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallFinish;

use Bitrix24\SDK\Core\Credentials\AuthToken;
use Bitrix24\SDK\Core\Credentials\Scope;
Expand Down
4 changes: 2 additions & 2 deletions src/Bitrix24Accounts/UseCase/InstallFinish/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\InstallFinish;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallFinish;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Exceptions\Bitrix24AccountNotFoundException;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;
use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface;
use Bitrix24\SDK\Lib\Bitrix24Accounts\Exceptions\MultipleBitrix24AccountsFoundException;
use Bitrix24\Lib\Bitrix24Accounts\Exceptions\MultipleBitrix24AccountsFoundException;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/UseCase/InstallStart/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\InstallStart;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallStart;

use Bitrix24\SDK\Core\Credentials\AuthToken;
use Bitrix24\SDK\Core\Credentials\Scope;
Expand Down
4 changes: 2 additions & 2 deletions src/Bitrix24Accounts/UseCase/InstallStart/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\InstallStart;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\InstallStart;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Events\Bitrix24AccountCreatedEvent;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;
use Bitrix24\SDK\Lib\Bitrix24Accounts\Entity\Bitrix24Account;
use Bitrix24\Lib\Bitrix24Accounts\Entity\Bitrix24Account;
use Carbon\CarbonImmutable;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
Expand Down
2 changes: 1 addition & 1 deletion src/Bitrix24Accounts/UseCase/RenewAuthToken/Command.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\RenewAuthToken;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\RenewAuthToken;

use Bitrix24\SDK\Core\Response\DTO\RenewedAuthToken;

Expand Down
4 changes: 2 additions & 2 deletions src/Bitrix24Accounts/UseCase/RenewAuthToken/Handler.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

declare(strict_types=1);

namespace Bitrix24\SDK\Lib\Bitrix24Accounts\UseCase\RenewAuthToken;
namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\RenewAuthToken;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountInterface;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Entity\Bitrix24AccountStatus;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Exceptions\Bitrix24AccountNotFoundException;
use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;
use Bitrix24\SDK\Application\Contracts\Events\AggregateRootEventsEmitterInterface;
use Bitrix24\SDK\Lib\Bitrix24Accounts\Exceptions\MultipleBitrix24AccountsFoundException;
use Bitrix24\Lib\Bitrix24Accounts\Exceptions\MultipleBitrix24AccountsFoundException;
use Psr\Log\LoggerInterface;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;

Expand Down
14 changes: 14 additions & 0 deletions src/Bitrix24Accounts/UseCase/SaveAccount/Command.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?php

declare(strict_types=1);

namespace Bitrix24\Lib\Bitrix24Accounts\UseCase\SaveAccount;

use Bitrix24\SDK\Application\Contracts\Bitrix24Accounts\Repository\Bitrix24AccountRepositoryInterface;

readonly class Command
{
public function __construct(
public Bitrix24AccountRepositoryInterface $bitrix24AccountRepository
){}
}
Loading
Loading