-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Rename dbal business methods and add default conversion (#288)
* Rename dbal business methods and add default conversion * Change naming * allow for int and string conversion * php 8 support * test on php 8 * php 8.2 on split testing * php 8 compatibility
- Loading branch information
Showing
18 changed files
with
326 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
packages/Dbal/tests/Fixture/DbalBusinessInterface/ActivityService.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\Dbal\Fixture\DbalBusinessInterface; | ||
|
||
use Ecotone\Dbal\Attribute\DbalQuery; | ||
use Ecotone\Dbal\Attribute\DbalWrite; | ||
use Ecotone\Dbal\DbaBusinessMethod\FetchMode; | ||
|
||
interface ActivityService | ||
{ | ||
#[DbalWrite('INSERT INTO activities VALUES (:personId, :activity, :time)')] | ||
public function add(string $personId, string $activity, \DateTimeImmutable $time): void; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
#[DbalQuery( | ||
'SELECT person_id FROM activities WHERE type = :activity AND occurred_at >= :atOrAfter', | ||
fetchMode: FetchMode::FIRST_COLUMN | ||
)] | ||
public function findAfterOrAt(string $activity, \DateTimeImmutable $atOrAfter): array; | ||
|
||
/** | ||
* @return string[] | ||
*/ | ||
#[DbalQuery( | ||
'SELECT person_id FROM activities WHERE type = :activity AND occurred_at < :atOrAfter', | ||
fetchMode: FetchMode::FIRST_COLUMN | ||
)] | ||
public function findBefore(string $activity, \DateTimeImmutable $atOrAfter): array; | ||
|
||
#[DbalWrite('INSERT INTO activities VALUES (:personId, :activity, :time)')] | ||
public function store(PersonId $personId, string $activity, \DateTimeImmutable $time): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
packages/Dbal/tests/Fixture/DbalBusinessInterface/DateTimeToDayStringConverter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\Dbal\Fixture\DbalBusinessInterface; | ||
|
||
use Ecotone\Messaging\Attribute\Converter; | ||
|
||
final class DateTimeToDayStringConverter | ||
{ | ||
#[Converter] | ||
public function to(\DateTimeInterface $dateTime): string | ||
{ | ||
return $dateTime->format('Y-m-d'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
packages/Dbal/tests/Fixture/DbalBusinessInterface/PersonId.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\Dbal\Fixture\DbalBusinessInterface; | ||
|
||
final class PersonId | ||
{ | ||
public function __construct(private string $id) | ||
{ | ||
|
||
} | ||
|
||
public function __toString(): string | ||
{ | ||
return $this->id; | ||
} | ||
} |
2 changes: 0 additions & 2 deletions
2
packages/Dbal/tests/Fixture/DbalBusinessInterface/PersonNameDTOConverter.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.