Skip to content

Commit c7397b0

Browse files
authored
Merge pull request #307 from wayofdev/feat/bump
2 parents 2e74c14 + 54de09a commit c7397b0

File tree

4 files changed

+129
-2
lines changed

4 files changed

+129
-2
lines changed

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ext-pdo": "*",
2020
"cycle/annotated": "*",
2121
"cycle/database": "^2.4",
22+
"cycle/entity-behavior": "^1.2",
2223
"cycle/migrations": "^4.0",
2324
"cycle/orm": "^2.3",
2425
"cycle/schema-migrations-generator": "^2.1",

composer.lock

Lines changed: 112 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/cycle.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,4 +235,10 @@
235235
// \Cycle\ORM\Config\RelationConfig::RELATION => \Cycle\ORM\Relation\Embedded::class,
236236
// ],
237237
],
238+
239+
/*
240+
* Enables support of SoftDelete and other features from cycle/entity-behavior package
241+
* @see https://github.com/cycle/entity-behavior
242+
*/
243+
'load_cycle_behavior' => true,
238244
];

src/Bridge/Laravel/Providers/Registrators/RegisterORM.php

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66

77
use Cycle\Database\DatabaseProviderInterface;
88
use Cycle\ORM\Config\RelationConfig;
9+
use Cycle\ORM\Entity\Behavior\EventDrivenCommandGenerator;
910
use Cycle\ORM\EntityManager;
1011
use Cycle\ORM\EntityManagerInterface;
1112
use Cycle\ORM\Factory;
@@ -39,9 +40,17 @@ public function __invoke(Application $app): void
3940
});
4041

4142
$app->singleton(ORMInterface::class, function (Application $app): ORMInterface {
43+
$commandGenerator = null;
44+
$loadEntityBehavior = config('cycle.load_entity_behavior', true);
45+
46+
if (true === $loadEntityBehavior) {
47+
$commandGenerator = new EventDrivenCommandGenerator($app->get(SchemaInterface::class), $app);
48+
}
49+
4250
return new ORM(
4351
factory: $app->get(FactoryInterface::class),
44-
schema: $app->get(SchemaInterface::class)
52+
schema: $app->get(SchemaInterface::class),
53+
commandGenerator: $commandGenerator
4554
);
4655
});
4756

0 commit comments

Comments
 (0)