class \mpf\web\Controller

class \mpf\web\Controller

-no description found-

Attributes
protected \mpf\interfaces\HtmlRequestInterface $request

Connection to active request class;

public string $defaultAction = "index"

Name of the default controller action;

public string $currentAction

Name of the current action;

public bool $safeClassOptions = false

Used by WebApp so that it won't send user $_GET options to class attributes;

public string $viewsFolder = "{MODULE_FOLDER}views{DIRECTORY_SEPARATOR}pages{DIRECTORY_SEPARATOR}{CONTROLLER}"

Path to views folder.

public string $layoutFolder = "{MODULE_FOLDER}views{DIRECTORY_SEPARATOR}layout"

Path to current layout

public bool $showLayout = true

If there is no need for layout then set this to false;

public bool $showLayoutOnAjax = false

Set if it should show or not layout when is an ajax request

public string $pageLayout

If set it will use this as current page layout, if it's not set then it will get action name as layout.

private mixed $_displayVars = []

-no description found-

private bool $error

Records if there was an error or not when trying to call the method.

Methods

public \mpf\web\Controller assign (string $name, mixed $value)

  • $name

    -no description found-

  • $value

    -no description found-

-no description found-

public mixed display (string $file, array $vars = [])

  • $file

    -no description found-

  • $vars

    -no description found-

Display a php file page.

protected bool applyParamsToClass ()

Apply request options to class also, not just method params;

public mixed run (mixed $arguments = [])

  • $arguments

    -no description found-

-no description found-

public \mpf\web\Controller setRequest (\mpf\interfaces\HtmlRequestInterface $request)

  • $request

    -no description found-

Set a request object;

public \mpf\interfaces\HtmlRequestInterface getRequest ()

Get controller request object;

public \mpf\web\Controller setActiveAction (string $name)

  • $name

    -no description found-

Set/change current action;

public string getActiveAction ()

Get active action name;

public mixed setPageLayout (string $name)

  • $name

    -no description found-

Used to change layout for active page. By default it will search by page name, but if this is set then the new name will be used.

public bool goToPage (string $controller, string $action = "index", array $params = [], string $module = null)

  • $controller

    Controller name where it must be redirected

  • $action

    Action name where it must be redirected. Index is the default selected action

  • $params

    Optional a list of params can be added also

  • $module

    Optional a different module

Shortcut to request->goToPage(). It will redirect user to selected page

public bool goToAction (string $action, array $params = [])

  • $action

    -no description found-

  • $params

    -no description found-

Similar to goToPage() this will actually redirect to a action inside this controller.

public null goToURL (string $url)

  • $url

    -no description found-

Similar to the above methods, this is another shortcut to a request method called goToURL. It will redirect the user to the selected string URL.

public null goBack ()

Shortcut to request::goBack() method;

public string getWebRoot ()

A shortcut to get web root faster from view.

public string getLinkRoot ()

A shortcut to get link root faster from view.

public string getName ()

Get this controller's name. It does that by checking the name of the class currently instantiated.

protected mixed beforeAction (mixed $actionName)

  • $actionName

    -no description found-

-no description found-

protected mixed afterAction (mixed $actionName, mixed $result)

  • $actionName

    -no description found-

  • $result

    -no description found-

-no description found-

public string[] getMethodParameters (string $name, string[] $options)

  • $name

    -no description found-

  • $options

    -no description found-

Read parameters for searched method;

public mixed callMethod (string $methodName, string[] $options)

  • $methodName

    -no description found-

  • $options

    -no description found-

Call selected method using selected options;