Helpers

Helpers are a simple way to add features to Walrus Framework, all helpers are in the app/helpers/ directory

Using Helpers

To use a Helper in your controller or model you can use the getHelper method, the first parameter is the helper name and the second is a boolean to make the function return a new instance of the helper or an already instantiated one if it exist

    WalrusHelpers::getHelper('name', true);

To call a helper from your template you need to use the $helpers variable which is an array containing an instance of all the helpers

Plain PHP example

    $helpers['name']->method();

Smarty example

    {$helpers.name->method()}
Creating a Helper

To create your own helper use this basic syntax

    namespace app\core\helpers;

    /**
     * Class Test
     * @package app\core\helpers
     */
    class Test
    {

        public function makeTest()
        {

        }
    }

Your helper as to be in the app/helpers/ directory.