Passing arguments to a template from a Controller
CROSP opened this issue · comments
Hi,
First of all, thanks for a great library and architecture definition.
I have just started applying this architecture. Currently, I am trying to figure out how to pass some arguments from a Controller
to a template.
Consider, we have a BaseController
class and it has the getMenuItems
method, some other controllers may override this method to provide additional items.
public function getMenuItems() {
return [];
}
In controller I pass a feature class to the serve
method:
public function homePage() {
return $this->serve( HomePageDashboardFeature::class, $this->getMenuItems());
}
However this doesn't work.
Maybe I am doing something wrong, but I am trying to move all common functionality into base classes.
I can create a base Feature
and move all these methods there, however not sure whether this will be the right decision.
What is a better way to handle such cases?
Thanks.
return $this->serve(HomePageDashboardFeature::class, ['argReceive' => $arg]);
in HomePageDashboardFeature constructor
__construct(TypeReceive $argReceive) or __construct($argReceive)
@CROSP did the suggestion of @ayrtonmsa work? I would've suggested the same 👍