You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With many other presenter packages out there, I keep coming back to this one for its simplicity and flexibility (others seem to limit themselves to much more restricted use-cases).
Anyway, tried adding a service to a presenter constructor, since the service contains functionality used across a number of the presenter methods:
public function __construct($entity, protected OrderService $orderService)
{
parent::__construct($entity);
}
This did not work, as the additional parameter was not being set in PresentableTrait:
$this->presenterInstance = new $this->presenter($this);
So this tried this in PresentableTrait instead, and it worked a treat:
Now my order presenter class has $this->orderService at its disposal.
Now, I know I can extend the trait with this fix (or something similar - this is first draft to check viability) for myself, but is this something that could be useful for this package? It should be possible for it to work across all the supported Laravel versions.
Having to include $entity to pass up to the parent is, unfortunately, a little messy.
The text was updated successfully, but these errors were encountered:
With many other presenter packages out there, I keep coming back to this one for its simplicity and flexibility (others seem to limit themselves to much more restricted use-cases).
Anyway, tried adding a service to a presenter constructor, since the service contains functionality used across a number of the presenter methods:
This did not work, as the additional parameter was not being set in
PresentableTrait
:So this tried this in
PresentableTrait
instead, and it worked a treat:Now my order presenter class has
$this->orderService
at its disposal.Now, I know I can extend the trait with this fix (or something similar - this is first draft to check viability) for myself, but is this something that could be useful for this package? It should be possible for it to work across all the supported Laravel versions.
Having to include
$entity
to pass up to the parent is, unfortunately, a little messy.The text was updated successfully, but these errors were encountered: