Table of Contents
Splint Loader
splint() function
The splint loader function is accessed by
$this->load->splint();
Loading a Splint Object
$this->load->splint($splint);
This will return a Splint Object.
$bootstrap = $this->load->splint("zoey/bootstrap"); $data = array("title" => "My Website"); $bootstrap->load->view("responsive_header", $data); $bootstrap->load->view("footer");
Parameters For Libraries
$this->load->splint($splint, $autoload, $params, $alias);
Parameter | Description | Required | Examples |
---|---|---|---|
splint (string) | The name of the splint package to load or search from. If only this argument is supplied, the function will return a Splint Object instead. | Yes | denver/github, cynobit/blogger |
autoload (string)/(array) | The autoload parameter specifies the class or resource to be loaded if supplied as a string (see Auto-load Prefixes for more about this). To load multiple libraries or resources, supply an array of associative arrays of arrays. See an Example. | Yes | $this->load->splint( "francis94c/ci-prefeence", "+CIPreference", null, "alias"); |
params (array) | an associative array of parameters. these are usually defined in the README file of any package you want to use | No | $params = array("key" => "value"); |
alias (string) | The name of the resulting object from which features of the library are accessed. | No | $this->alias->someMethod(); |
Parameters for Models
$this->load->splint($splint, $model, $alias);
Parameter | Description | Examples |
---|---|---|
splint (string) | The name of the splint package to load or search from. | denver/github, cynobit/blogger |
model (string)/(array) | The model parameter specifies the model class to be loaded. It must be prefixed with a * character to load the specified model. see Auto-load Prefixes for more about this). | $this->load->splint("francis94c/ci-preference", "*CIModel", "ci_model"); |
alias (string) | The name of the resulting object from which features of the model are accessed. | $this->alias->someMethod(); |
Parameters For Configs
$this->load->splint($splint, $config);
Parameter | Description | Examples |
---|---|---|
splint (string) | The name of the splint package to load or search from. | denver/github, cynobit/blogger |
config (string) | The name of the config file to load. | “server_config” |
Parameters For Views
$this->load->splint($splint, $view);
Parameter | Description | Examples |
---|---|---|
splint (string) | The name of the splint package to load or search from. | denver/github, cynobit/blogger |
config (string) | The name of the view to load. | “server_config” |
Parameters For Helpers
$this->load->splint($splint, $helper);
Parameter | Description | Examples |
---|---|---|
splint (string) | The name of the splint package to load or search from. | denver/github, cynobit/blogger |
config (string) | The name of the helper to load. | “server_config” |
bind() function
An alternative to creating a Splint Object is the bind()
function.
Ideally, a Splint object is meant to be used in a situation where you need to load multiple resources from one package (where supplying the full range of arguments to the splint()
function could be strenuous). The Splint object is a representation the package, that lets you load resources as you wish by specifying the package once.
$this->load->bind($splint, $bind);
Parameters
Parameter | Description | Required | Examples |
---|---|---|---|
$splint(string) | The splint package to load. | Yes | zoey/bootstrap |
$bind (null object) | The object that the specified $splint should be bound to. you do not need to declare this argument prior to calling the function. If omitted, the function will return the Splint object instead. | No | $this→load→bind( zoey/bootstrap, $bootstrap) |
For example, the zoey/bootstrap
package could be loaded with then bind
function and used as follows.
$this->load->bind("zoey/bootstrap", $bootstrap); $data = array("title" => "My Website"); $bootstrap->load->view("responsive_header", $data); $bootstrap->load->view("footer"); // OR $bootstrap = $this->load->bind("zoey/bootstrap"); $data = array("title" => "My Website"); $bootstrap->load->view("responsive_header", $data); $bootstrap->load->view("footer");
package() function
This function allows you to specify a package name only that allows Splint to load resources specified automatically by the vendor of the Splint package.
$this->load->package($splint);
For instance, if a package's splint.json
descriptor file contains the below autoload
key defined along side other keys as follows.
{ "....": "............", "autoload": { "libraries" : [ ["Class", "alias"] ] } }
If the name of the package is for instance, zoey/bootstrap
, a call to the package()
function with the package name passed as an argument will automatically load the class with the alias as defined in the descriptor. See the below example.
$this->load->package("zoey/bootstrap"); $this->alias->someMethod();
The resources that could be auto-loaded by vendors include:
- Libraries
- Models
- Helpers
- Configs