Is there a way to pass constructor arguments for dependencies when using the automatically generated factory classes?
I have an object structure that I would instantiate like this without the object manager:
new A(
new AA(
new AAA(
'xyz' <-- value determined at runtime
)
),
new AB(
new ABA(),
new ABB()
[1,2,3] <-- value determined at runtime
),
new AC(
...
)
);
Now I could replace this with a mix of factories and constructor injected arguments1, but I'm wondering if there is another way, something like this:
$aFactory->create(
[
AAA::class => ['param1' => 'xyz'],
AB::class => ['param3' => [1,2,3]],
]
);
Alternatively it would also be useful if I could define a constructor argument to be fetched from a certain method with the type
definition in di.xml
.
Is there anything like this?
1) like this
$aFactory->create(
[
'aa' => $aaFactory->create(
[
'aaa' => $aaaFactor->create(
[
'param1' => 'xyz'
]
)
]
),
'ab' => $abFactory->create(
[
'param3' => [1,2,3]
]
)
]
);
But what I'm trying to avoid is having to depend on all these factories
$data
argument ? magento.stackexchange.com/a/118040/2380$data
array instead of injecting class dependencies".