Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #500 from mehlah/api-docs

Api docs
  • Loading branch information...
commit eeee1cba7fee1927851cb9ffa46cba90cf141656 2 parents 96ae2ff + c4e6436
@nateabele nateabele authored
View
8 action/Controller.php
@@ -132,6 +132,12 @@ public function __construct(array $config = array()) {
parent::__construct($config + $defaults);
}
+ /**
+ * Populates the `$response` property with a new instance of the `Response` class passing it
+ * configuration, and sets some rendering options, depending on the incoming request.
+ *
+ * @return void
+ */
protected function _init() {
parent::_init();
$this->request = $this->request ?: $this->_config['request'];
@@ -195,7 +201,7 @@ public function __invoke($request, $dispatchParams, array $options = array()) {
/**
* This method is used to pass along any data from the controller to the view and layout
*
- * @param array $data sets of <variable name> => <variable value> to pass to view layer.
+ * @param array $data sets of `<variable name> => <variable value>` to pass to view layer.
* @return void
*/
public function set($data = array()) {
View
17 data/Model.php
@@ -331,8 +331,9 @@ public static function __init() {
* attributes, as well as obtain a handle to the configured persistent storage connection.
*
* @param array $options Possible options are:
- * - `meta`: Meta-information for this model, such as the connection.
- * - `finders`: Custom finders for this model.
+ * - `meta`: Meta-information for this model, such as the connection.
+ * - `finders`: Custom finders for this model.
+ *
* @return void
*/
public static function config(array $options = array()) {
@@ -495,7 +496,7 @@ public static function finder($name, $options = null) {
}
/**
- * Set/get method for `Model` metadata.
+ * Gets or sets Model's metadata.
*
* @see lithium\data\Model::$_meta
* @param string $key Model metadata key.
@@ -659,8 +660,8 @@ public static function hasField($field) {
* example:
*
* {{{
- * $post = Posts::create(array("title" => "New post"));
- * echo $post->title; // echoes "New post"
+ * $post = Posts::create(array('title' => 'New post'));
+ * echo $post->title; // echoes 'New post'
* $success = $post->save();
* }}}
*
@@ -671,8 +672,8 @@ public static function hasField($field) {
* database, without actually querying the database:
*
* {{{
- * $post = Posts::create(array("id" => $id, "moreData" => "foo"), array("exists" => true));
- * $post->title = "New title";
+ * $post = Posts::create(array('id' => $id, 'moreData' => 'foo'), array('exists' => true));
+ * $post->title = 'New title';
* $success = $post->save();
* }}}
*
@@ -1144,4 +1145,4 @@ protected static function &_connection() {
}
}
-?>
+?>
View
62 template/helper/Html.php
@@ -117,19 +117,26 @@ public function charset($encoding = null) {
/**
* Creates an HTML link (`<a />`) or a document meta-link (`<link />`).
*
- * If `$url` starts with `"http://"` or `"https://"`, this is treated as an external link.
+ * If `$url` starts with `'http://'` or `'https://'`, this is treated as an external link.
* Otherwise, it is treated as a path to controller/action and parsed using
* the `Router::match()` method (where `Router` is the routing class dependency specified by
* the rendering context, i.e. `lithium\template\view\Renderer::$_classes`).
*
* If `$url` is empty, `$title` is used in its place.
*
- * @param string $title The content to be wrapped by an `<a />` tag.
+ * @param string $title The content to be wrapped by an `<a />` tag,
+ * or the `title` attribute of a meta-link `<link />`.
* @param mixed $url Can be a string representing a URL relative to the base of your Lithium
* application, an external URL (starts with `'http://'` or `'https://'`), an
* anchor name starting with `'#'` (i.e. `'#top'`), or an array defining a set
* of request parameters that should be matched against a route in `Router`.
- * @param array $options Array of HTML s and other options.
+ * @param array $options The available options are:
+ * - `'escape'` _boolean_: Whether or not the title content should be escaped or not. Defaults to true.
+ * - `'type'` _string_: The meta-link type, which is looked up in `Html::$_metaLinks`.
+ * By default it accepts `atom`, `rss` and `icon`.
+ * If a `type` is specified, this method will render a document meta-link (`<link />`),
+ * instead of an HTML link (`<a />`).
+ * - any other options specified are rendered as HTML attributes of the element.
* @return string Returns an `<a />` or `<link />` element.
*/
public function link($title, $url = null, array $options = array()) {
@@ -147,11 +154,18 @@ public function link($title, $url = null, array $options = array()) {
/**
* Returns a JavaScript include tag (`<script />` element). If the filename is prefixed with
- * `"/"`, the path will be relative to the base path of your application. Otherwise, the path
+ * `'/'`, the path will be relative to the base path of your application. Otherwise, the path
* will be relative to your JavaScript path, usually `webroot/js`.
*
- * @param mixed $path String path to JavaScript file, or an array of paths.
- * @param array $options
+ * @link http://lithify.me/docs/manual/handling-http-requests/views.wiki
+ * @param mixed $path String The name of a JavaScript file, or an array of names.
+ * @param array $options Available options are:
+ * - `'inline'` _boolean_: Whether or not the `<script />` element should be output inline.
+ * When set to false, the `scripts()` handler prints out the script, and other specified scripts
+ * to be included in the layout. Defaults to true.
+ * This is useful when page-specific scripts are created inline in the page,
+ * and you'd like to place them in the <head /> along with your other scripts.
+ * - any other options specified are rendered as HTML attributes of the element.
* @return string
* @filter This method can be filtered.
*/
@@ -180,11 +194,22 @@ public function script($path, array $options = array()) {
}
/**
- * Creates a link element for CSS stylesheets.
+ * Creates a `<link />` element for CSS stylesheets or a `<style />` tag. If the filename is prefixed with
+ * `'/'`, the path will be relative to the base path of your application. Otherwise, the path
+ * will be relative to your Stylesheets path, usually `webroot/css`.
*
- * @param mixed $path The name of a CSS style sheet in `/app/webroot/css`, or an array
+ * @param mixed $path The name of a CSS stylesheet in `/app/webroot/css`, or an array
* containing names of CSS stylesheets in that directory.
- * @param array $options Array of HTML attributes.
+ * @param array $options Available options are:
+ * - `'inline'` _boolean_: Whether or not the `<style />` element should be output inline.
+ * When set to false, the `styles()` handler prints out the styles, and other specified styles
+ * to be included in the layout. Defaults to true.
+ * This is useful when page-specific styles are created inline in the page,
+ * and you'd like to place them in the <head /> along with your other styles.
+ * - `'type'` _string_: By default, accepts `stylesheet` or `import`,
+ * which respectively correspond to `style-link` and `style-import` strings templates
+ * defined in `Html::$_strings`.
+ * - any other options specified are rendered as HTML attributes of the element.
* @return string CSS <link /> or <style /> tag, depending on the type of link.
* @filter This method can be filtered.
*/
@@ -216,16 +241,16 @@ public function style($path, array $options = array()) {
}
/**
- * Creates a tag for the ```<head>``` section of your document.
+ * Creates a tag for the `<head>` section of your document.
*
* If there is a rendering context, then it also pushes the resulting tag to it.
*
- * The ```$options``` must match the named parameters from ```$_strings``` for the
- * given ```$tag```.
+ * The `$options` must match the named parameters from `$_strings` for the
+ * given `$tag`.
*
- * @param string $tag the name of a key in ```$_strings```
- * @param array $options the options required by ```$_strings[$tag]```
- * @return mixed a string if successful, otherwise NULL
+ * @param string $tag the name of a key in `$_strings`
+ * @param array $options the options required by `$_strings[$tag]`
+ * @return mixed a string if successful, otherwise `null`
* @filter This method can be filtered.
*/
public function head($tag, array $options) {
@@ -244,9 +269,12 @@ public function head($tag, array $options) {
}
/**
- * Creates a formatted <img /> element.
+ * Creates a formatted `<img />` element.
*
- * @param string $path Path to the image file, relative to the app/webroot/img/ directory.
+ * @param string $path Path to the image file. If the filename is prefixed with
+ * `'/'`, the path will be relative to the base path of your application.
+ * Otherwise the path will be relative to the images directory, usually `app/webroot/img/`.
+ * If the name starts with `'http://'`, this is treated as an external url used as the `src` attribute.
* @param array $options Array of HTML attributes.
* @return string
* @filter This method can be filtered.
View
18 template/readme.wiki
@@ -2,7 +2,7 @@
Views have a special syntax for outputting escaped text. The standard way to
output escaped text in your views from Lithium is as follows: {{{
-<?=$variable;?>
+<?=$variable; ?>
}}}
This is where a lot of confusion comes in, because it is commonly misunderstood
@@ -22,16 +22,16 @@ familiar syntax and it helps developers focus more on what data _should not_ be
escaped vs. what data _needs_ to be escaped.
One special case situation to take _important_ note of, is the use of
-`<?=$this->foo()?>`. In this scenario, the code is translated to
+`<?=$this->foo(); ?>`. In this scenario, the code is translated to
`<?php echo $this->foo(); ?>` rather than being filtered through `$h()` as with
the former explanation. When direct access to a method or property on `$this` is
contained in the shorthands syntax, it will be output as normal without being
filtered. This is to make it easier to work with helpers that return markup.
An example would be something like: {{{
-<?=$this->form->create();?>
+<?=$this->form->create(); ?>
... my form here ...
-<?=$this->form->end();?>
+<?=$this->form->end(); ?>
}}}
**Note:** `$h()` is the HTML escape function used in views.
@@ -88,7 +88,7 @@ class Custom extends \lithium\template\Helper {
You can then use your helper in templates as follows:
{{{
-<?=$this->custom->greeting("World"); ?>
+<?=$this->custom->greeting('World'); ?>
}}}
Your custom helper will then be auto-loaded into the templating engine from your application or a
@@ -122,10 +122,10 @@ template. For more information on the load order of classes, see
#### Rendering elements
Elements are reusable view snippets that you can use in several views and layouts.
-You can reference it like so:
+You can reference it like so:
{{{
echo $this->_render('element', 'menu');
-}}}
+}}}
Where `menu` is the name of your element file, in this example `views/elements/menu.html.php`. When using `$this->_render()`, all of the variables set in the controller are available to the element template. You can pass variables declared in the view or additional static content using the third parameter to `$this->_render()`:
{{{
@@ -139,7 +139,7 @@ echo $this->_render('element', 'menu', array(
If you need the element template to not have access to existing data passed to the parent template, use the alternate syntax that calls the `View` render method directly:
{{{
echo $this->view()->render(
- array('element' => 'menu'),
+ array('element' => 'menu'),
array('var1' => $var1, 'var2' => $var2)
);
}}}
@@ -148,4 +148,4 @@ echo $this->view()->render(
- [ View](template/View)
- [ Renderer](template/view/Renderer)
- - [ File adapter](template/view/adapter/File)
+ - [ File adapter](template/view/adapter/File)
Please sign in to comment.
Something went wrong with that request. Please try again.