V4 to V5¶
Repository->put()
¶
Repository->remove()
¶
Repository->effect()
¶
Transactions¶
use Formal\ORM\Adapter\Transaction\Failure
use Innmind\Immutable\Either;
$manager
->transactional(static function() {
if (/* some condition */) {
return Either::right(new SomeValue);
}
return Either::left(new SomeError);
})
->match(
static fn(SomeValue $value) => domSomething($value),
static fn(SomeError|Failure $value) => match (true) {
$value instanceof Failure => throw $value->unwrap(),
default => domSomething($value),
},
);
Errors happening during the transaction commit/rollback are now returned on the left side instead of thrown to let you decide if you prefer using exceptions or a monadic style.