Answer the question
In order to leave comments, you need to log in
Dependency Inversion in ORM. Bike or is there a solution?
I implement dependency inversion in the ORM so that the basic logic is applied already at the stage of obtaining the object. In this code, there is actually an example of injection rules based on database fields (in my case, these are full-fledged objects, not properties). Are there already similar implementations (in any programming language)?
public function __construct(
\App\Repository\Tariff\type $TariffType,
\App\Repository\Tariff\limit $TariffLimit,
\App\Repository\Clients\balance $Balance,
\Kernel\Models\Elements\OperatorItem $Oi
) {
$Oi->def('\App\Logic\Balance\Balance');
$Oi->reg('\App\Logic\Balance\BalanceNegative', [
$TariffType->equals(function($v){
return $v == 1;
}),
$Balance->equals(function($v) use ($TariffLimit){
return $v < ($TariffLimit*-1);
})
]);
$Oi->reg('\App\Logic\Balance\BalanceNegative', [
$TariffType->equals(function($v){
return $v == 0;
}),
$Balance->equals(function($v){
return $v < 0;
})
]);
return $Oi->getInstance();// new \App\Logic\Balance\BalanceFailure()
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question