Skip to content

V4 to V5

Repository->put()

$repository->put($aggregate);
$repository->put($aggregate)->unwrap();

Repository->remove()

$repository->remove($idOrSpecification);
$repository->remove($idOrSpecification)->unwrap();

Repository->effect()

$repository->effect($effect);
$repository->effect($effect)->unwrap();

Transactions

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 $value) => domSomething($value),
    );
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.