Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Minor API docs updates.

  • Loading branch information...
commit b7abee1091cc21c03b8db35d724a416fed8c89b8 1 parent 5f16dca
Mehdi Lahmam mehlah authored
Showing with 25 additions and 18 deletions.
  1. +7 −1 action/Controller.php
  2. +9 −8 data/Model.php
  3. +9 −9 template/readme.wiki
8 action/Controller.php
View
@@ -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()) {
17 data/Model.php
View
@@ -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() {
}
}
-?>
+?>
18 template/readme.wiki
View
@@ -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.