-
Notifications
You must be signed in to change notification settings - Fork 0
acorn
This is the class you'll be using the most. You don't need to know much about the other classes except <AN_Model>.
Alias for AN_Model::defineModel
Returns database connection using the specified settings. Required keys are: user, password, database, host, adapter.
<?php Acorn::database(array('user' => 'skrat', 'password' => 'nut', 'database' => 'acorn_tree', 'host' => 'localhost', 'adapter' => 'mysql')) ?>
{AN_Database}
Database connection.
Sets status and displays error.
| code | int | Error code |
Loads named file with the given type.
<?php Acorn::load('model', 'User'); ?>
| type | String | Type of file. |
| name | String | - Name of file. |
{bool}
True if successfully loaded file.
Searches Acorn::$include_paths for the specified file.
<?php $path = Acorn::filePath('model', 'User'); ?>
| type | String | Type of file - it gets converted to lowercase (e.g. 'model'). |
| name | String | Name of file - it gets converted to lowercase (e.g. 'User'). |
{bool | String}
False if no file exists, otherwise path of file.
Renders the view at the specified path.
<?php Acorn::renderView('./users/info'); ?>
| file | String | Path to the view file. |
| layout | String | Name of the layout to render the view in. If null no layout will be used. (Default: layout) |
Renders a partial with the specified name and returns it as a string.
| name | String | Name of the partial to render (e.g. 'posts/detail' would be 'posts/_detail.php' on disk). |
| var | Mixed | Variable to be given the name of the partial (e.g. name = 'posts/detail', $detail = $var). |
| extra_vars | Array | Variables for the partial to use. (e.g. array('user' => $user, 'time' => time())) |
{String}
Contents of the rendered partial.
Connects a URL to a callback with default parameters and regular expression requirements.
<?php
Acorn::route('GET /posts/:id', 'viewPost', null, array('id' => '\d+'));
Acorn::route('GET /pages/:name', 'viewPage', array('name' => 'home'));
?>
| url | String | The URL to match. |
| callback | Mixed | The callback to be used when this route is matched. |
| defaults | Array | The default paramenters to be passed to the callback. |
| regex | Array | Regular expressions to define the segments in the URL. |
Converts the given parameters into a URL appropriate for a link.
<?php echo Acorn::url(array('action' => 'view', 'id' => 1)); ?>
| params | Array | Array of key/value pairs to match to a route. |
| method | String | Request method that matches the method at the beginning of the route. |
{String}
The URL as a string if a route is found. Null if no match is made.
Calls the first matched route for $url. If no parameters are passed the current request method and request uri are used.
| url | String | The URL to route. Must have a request method at the beginning (e.g. "GET /"). |
Converts string to lowercase and replaces lowercase letter followed by a uppercase letter with the lowercase version of both separated by an underscore.
| str | String | String to underscore. |
{String}
Underscored version of string.