Differences
This shows you the differences between two versions of the page.
— |
app_developer:splint_app_controller_class [2019/06/04 01:20] (current) |
||
---|---|---|---|
Line 1: | Line 1: | ||
+ | ====== SplintAppConttroller Class ====== | ||
+ | The ''SplintAppController'' class just like ''CI_Controller'' class is the Class your Splint application controller need to extend to work properly and have access to important variables and methods. | ||
+ | |||
+ | ===== Inherited Variables ===== | ||
+ | |||
+ | ==== [protected] $ci ==== | ||
+ | |||
+ | This variable is the same as the root Code Igniter instance object gotten from a call to ''get_instance()''. This variable enables you access loaded resources within your application and beyond. It also gives you access to all methods and variables which the ''$this'' variable will give you within a Class that extends ''CI_Controller'' Class.\\ | ||
+ | |||
+ | The example below shows how a loaded class within a SplinAppController is accessed. | ||
+ | |||
+ | <code php> | ||
+ | defined('BASEPATH') OR exit('No direct script access allowed'); | ||
+ | |||
+ | class Home extends SplintAppController { | ||
+ | |||
+ | function index() { | ||
+ | $this->load->splint("vendor/package_name", "+Class", null, "alias"); | ||
+ | $this->ci->alias->someMethod(); | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | If you would like to access the loaded resource with the ''$this'' variable, you will have to call the ''SplintAppController'' method ''bind()'' passing it the alias to bind to ''$this''. This function can take multiple aliases. See a modified example below. | ||
+ | |||
+ | <code php> | ||
+ | defined('BASEPATH') OR exit('No direct script access allowed'); | ||
+ | |||
+ | class Home extends SplintAppController { | ||
+ | |||
+ | function index() { | ||
+ | $this->load->splint("vendor/package_name", "+Class", null, "alias"); | ||
+ | $this->bind("alias"); | ||
+ | $this->alias->someMethod(); | ||
+ | } | ||
+ | } | ||
+ | </code> | ||
+ | |||
+ | ==== [protected] $params ==== | ||
+ | |||
+ | This variable holds the associative array passed to the call to ''$this->load->app()'' function when loading your application. access it's values like below. | ||
+ | |||
+ | <code php> | ||
+ | $this->params["paramN"]; | ||
+ | </code> | ||
+ | |||
+ | ==== [public] $splint ===== | ||
+ | |||
+ | This is the fully qualified name of your application, rather the first argument passed when loading your application with a call to ''$this->load->app()''. Of course, it's a string. You can use this if when loading a resource from your application package using the ''$this->load->splint()'' function. | ||
+ | |||
+ | ===== Inherited Methods ===== | ||
+ | |||
+ | ==== [protected] bind() ==== | ||
+ | |||
+ | This method as described above, binds specified aliases unto the ''$this'' variable (Your SplintAppController instance). This is mainly for convenience as it allows you use the ''$this'' variable with loaded resources rather than the ''$app'' variable. | ||
+ | |||
+ | <code php> | ||
+ | $this->bind("alias1", "alias2",........); | ||
+ | </code> | ||
+ | |||
+ | ==== [public] view() ==== | ||
+ | |||
+ | Loads a view from the application ''views'' folder, It has the same parameters as Code Igniter's view loading function. | ||
+ | |||
+ | ==== [public] library() ==== | ||
+ | |||
+ | Loads a library class from the application ''libraries'' folder, It has the same parameters as Code Igniter's library function loading function. | ||
+ | |||
+ | ==== [public] model() ==== | ||
+ | |||
+ | Loads a model from the application ''models'' folder, It has the same parameters as Code Igniter's model loading function. | ||
+ | |||
+ | ==== [public] fetch_param($param, $default) ==== | ||
+ | |||
+ | This gets a value from the ''$this->params'' array, returns the value of ''$default'' if it doesn't exist. The value of ''$default'' is ''false'' by default. | ||
+ | |||
+ | ==== [public] set_param($param, $value) ==== | ||
+ | |||
+ | Sets a parameter in the ''$this->params'' array. | ||
+ | |||
+ | ==== [public] view_path($view) ==== | ||
+ | |||
+ | Takes a ''$view'' argument and appends in front of it, the path to your package view folder. This is necessary when dealing with a different package that demands a view and intends to load it from the main Code Igniter view path. This function helps route it back to your package view folder. | ||
+ | |||
+ | ==== [protected] fill_params_in_array($params, &$array) ==== | ||
+ | |||
+ | Takes and array of parameter keys to load into ''$array'' from the ''$this->params'' array of they exist. | ||
+ | |||
+ | ==== [protected] parent_uri($uri) ==== | ||
+ | |||
+ | Takes a URI and appends in front the URI of its parent ''CI_Controller'', i.e. The Controller method where ''$this->load->app()'' was called from that began the app instance. | ||
+ | ===== NEXT ===== | ||
+ | |||
+ | [[app_developer:application_urls|Splint Application URLs and Helper Functions]] => \\ | ||
+ | |||
+ | ===== PREVIOUS ===== | ||
+ | |||
+ | <= [[app_developer:develop_and_distribute_a_splint_application|Develop and Distribute your First Splint Application]]\\ | ||
+ | |||
+ | ===== Other Topics ===== | ||
+ | |||
+ | [[app_developer:application_urls|Splint Application URLS and Helper Functions]]\\ | ||
+ | [[load_splint|Load Splint Libraries]]\\ | ||
+ | [[app_developer:loading_application_resources_within_the_application|Loading Splint Application Resources]]\\ |