Skip to content

Commit

Permalink
Add EntityBehaviorBootloader
Browse files Browse the repository at this point in the history
  • Loading branch information
msmakouz committed Jan 10, 2024
1 parent 696a920 commit fda5cc1
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 1 deletion.
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@
"spiral/validator": "^1.5",
"spiral/nyholm-bridge": "^1.3",
"spiral-packages/database-seeder": "^3.1",
"vimeo/psalm": "^4.27"
"vimeo/psalm": "^4.27",
"cycle/entity-behavior": "^1.2"
},
"autoload": {
"psr-4": {
Expand Down
19 changes: 19 additions & 0 deletions src/Bootloader/EntityBehaviorBootloader.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace Spiral\Cycle\Bootloader;

use Cycle\ORM\Transaction\CommandGeneratorInterface;
use Cycle\ORM\Entity\Behavior\EventDrivenCommandGenerator;
use Spiral\Boot\Bootloader\Bootloader;

final class EntityBehaviorBootloader extends Bootloader
{
public function defineBindings(): array
{
return [
CommandGeneratorInterface::class => EventDrivenCommandGenerator::class,
];
}
}
4 changes: 4 additions & 0 deletions tests/src/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,16 @@ public function defineBootloaders(): array

// Auth
CycleBridge\AuthTokensBootloader::class,

// Validation
CycleBridge\ValidationBootloader::class,

// Scaffolder
CycleBridge\ScaffolderBootloader::class,

// EntityBehavior
CycleBridge\EntityBehaviorBootloader::class,

// App
AppBootloader::class,
];
Expand Down
17 changes: 17 additions & 0 deletions tests/src/Bootloader/EntityBehaviorBootloaderTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

declare(strict_types=1);

namespace Spiral\Tests\Bootloader;

use Cycle\ORM\Entity\Behavior\EventDrivenCommandGenerator;
use Cycle\ORM\Transaction\CommandGeneratorInterface;
use Spiral\Tests\BaseTest;

final class EntityBehaviorBootloaderTest extends BaseTest
{
public function testThatEventDrivenCommandGeneratorIsBound(): void
{
$this->assertContainerBound(CommandGeneratorInterface::class, EventDrivenCommandGenerator::class);
}
}

0 comments on commit fda5cc1

Please sign in to comment.