Calling setters with more than one argument?
Is is possible to define attributes in a way that the corresponding method (a setter) is called with more than just one argument?
For example, assume I have an Order class that has an appendLineItem($item, $quantity) method.
Can I define my OrderFactory to include a method like...
class OrderFactory {
public function addItem($item, $quantity): self
{
return $this->addState(['appendLineItem' => [$item, $quantity]]);
}
The idea is that the attribute value is an array and would be mapped to parameters for the appendLineItem method.
Would a post-instantiate hook work for this?
I would indeed use a hook for this.
The requested behavior is currently not possible, and I think it could be complex to implement, since we use Symfony's property accessor to hydrate objects. And presently we don't have any clue to know if the array should be use as is or if it should be destructed and each item in the array would represent a parameter of the target method
I'm closing this since it's a stale issue, and I don't think we will ever support this (beside of using a post instantiate hook)