Improved Link() docs

This commit is contained in:
Ingo Schommer 2014-01-22 22:28:10 +13:00
parent 318073b05d
commit 53e790ff98

View File

@ -54,17 +54,25 @@ making any code changes to your controller.
so a `MyController` class is accessible through `http://localhost/MyController`. so a `MyController` class is accessible through `http://localhost/MyController`.
</div> </div>
## Link ## Linking to a controller
Return the link for this Controller. Should return a value that makes sense with your custom route. Each controller has a built-in `Link()` method,
which can be used to avoid hardcoding your routing in views etc.
The method should return a value that makes sense with your custom route (see above):
:::php :::php
<?php
class FastFood_Controller extends Controller { class FastFood_Controller extends Controller {
public function Link() { public function Link($action = null) {
return 'fastfood'; return Controller::join_links('fastfood', $action);
} }
} }
The [api:Controller::join_links()] invocation is optional, but makes `Link()` more flexible
by allowing an `$action` argument, and concatenates the path segments with slashes.
The action should map to a method on your controller. `join_links()` also supports
## Access Control ## Access Control
### Through $allowed_actions ### Through $allowed_actions