Releases: zenstruck/foundry
v2.8.0
This release introduces a new attribute #[AsFoundryHook], which allows to declare Foundry hooks as Symfony services. It also permits to have "global" hooks for all kind of objects created with Foundry:
final class FoundryHook
{
#[AsFoundryHook(Post::class)]
public function beforeInstantiate(BeforeInstantiate $event): void
{
// do something before the post is instantiated:
// $event->parameters is what will be used to instantiate the object, manipulate as required
// $event->objectClass is the class of the object being instantiated
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook(Post::class)]
public function afterInstantiate(AfterInstantiate $event): void
{
// $event->object is the instantiated Post object
// $event->parameters contains the attributes used to instantiate the object and any extras
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook(Post::class)]
public function afterPersist(AfterPersist $event): void
{
// this event is only called if the object was persisted
// $event->object is the persisted Post object
// $event->parameters contains the attributes used to instantiate the object and any extras
// $event->factory is the factory instance which creates the object
}
#[AsFoundryHook]
public function afterInstantiateGlobal(AfterInstantiate $event): void
{
// Omitting the class defines a "global" hook which will be called for all objects
}
}8dc0b1f feat(2.8): introduce #[AsFoundryHook] attribute (#986) by @nikophil
bf4549c feat(2.8): dispatch events (#974) by @nikophil
8516af1 docs: Remove array params on function alwaysForce (#1028) by @philpichet
5f3a6b1 feat: add hooks priority (#1029) by @nikophil
v2.7.9
v2.7.8
728c8f8 minor: Add default value to Factory::attributes (#1026) by @VincentLanglet
0fe1017 tests: ensure Doctrine lifecycle works (#1020) by @nikophil
1247b0b chore: remove paratest from dev dependencies (#1023) by @nikophil
11355a9 chore: add concurrency for all workflows (#1019) by @nikophil
fed6e4a chore: fix rector with bamarni (#1018) by @nikophil
545cf18 chore: split CIs and add concurrency (#1017) by @nikophil
17796f2 chore: add bc-check to CI (#1016) by @nikophil
b8ced9b chore: disable sync template for cs config (#1015) by @nikophil
b802463 chore: some housekeeping (#1014) by @nikophil
v2.7.7
v2.7.6
95d2a96 fix: autorefresh should work after kernel shutdown (#1011) by @nikophil
0ea8430 tests: ensure OneToMany relationships are refreshed (#1010) by @nikophil
3c6faff fix: RepositoryAssertion::exist() $criteria should allow mixed (#1007) by @nikophil
81cc97d minor: accept as story any child of Story (#1006) by @alsciende
e99f3b0 chore: run rector CI with PHPUnit 12 (#1002) by @nikophil
v2.7.5
v2.7.4
v2.7.3
45214f7 fix: revert adding PersistManager::findBy() (#996) by @nikophil
b36b9b3 chore: upgrade PHPStan (#997) by @nikophil
55f2689 fix: edge case with Doctrine Middleware & early kernel boot (#993) by @HypeMC
9fa21b3 fix(repository): use IN() when an array is passed (#995) by @nikophil
cad1466 fix: handle readonly when refreshing from repository decorator (#989) by @nikophil
b4b2ffe fix: Enhanced random method with additional safety check. (#991) by @sofwar