Fabriq Framework Docs

This page displays the APIs for controllers that are made available by the /core/Controller.class.php file's Fabriq class. Each function available for use is listed below with examples of how to use the function.

$this->controllerMethods()

Description

Returns an array of methods that are contained in the controller. With the exception of the methods defined by the base Controller class, the methods correspond to the actions in that controller.

Example(s)

// example controller
class myapp_controller extends Controller {
  function index() {
    global $actions;
    $actions = $this->controllerMethods();
  }
  // actions in myapp
}
 
// example view code for /app/views/myapp/index.view.php
for ($i = 0; $i < count($actions); $i++) {
  if (($actions[$i] != 'controllerMethods') && ($actions[$i] != 'hasMethod')) {
    echo "<p>{actions[$i]}</p>\n";
  }
}

Return type: array

error()

Description

This function returns the last error returned by the database or boolean FALSE if there is no error.

Example(s)

// get database error
$db_var_name->error();

Added in version: 1.1

Return type: string

$this->hasMethod($method)

Parameters

  • method – name of action to determine if it exists

Description

Determines whether or not the given action exists in the controller.

Example(s)

// example controller
class myapp_controller extends Controller {
  function view() {
    // view action code
  }
  function create() {
    // create action code
  }
  function destroy() {
    // destroy action code
  }
  function index() {
    if ($this->hasMethod('view')) {
      echo "<p>This controller has method <em>view</em></p>";
    }
    if (!$this->hasMethod('update')) {
      echo "<p>This controller does not have method <em>update</em></p>";
    }
  }
}

Return type: boolean