SolarPHP How to use unlimited functions in a View Helper
I was chatting on irc with dmytrok (kudos to him about the tip below) about the Solar View Helpers and it seems there's a very simple way of using multiple functions in a solar view helper.
As you know, for creating a Solar View Helper you create a class like:
- class Vendor_View_Helper_MyTest extends Solar_View_Helper {
- public function myTest()
- {
- // logic here
- }
- }
And then you can call it in your views by using $this->myTest() and all will go well.
For having multiple functions in that helper you must make it return the $this object so you can access the inside functions.
- class Vendor_View_Helper_MyTest extends Solar_View_Helper {
- public function myTest()
- {
- return $this;
- }
- public function Inside()
- {
- //logic here
- }
- }
Now you can access any function side the myTest helper like
- $this->myTest()->Inside();
Add new comment