Skip to content

Commit

Permalink
Merge pull request #551 from gringlas/patch-1
Browse files Browse the repository at this point in the history
Custom named controller actions
  • Loading branch information
josegonzalez committed Oct 7, 2017
2 parents ae533de + c972769 commit c505400
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions docs/actions/custom.rst
Original file line number Diff line number Diff line change
Expand Up @@ -93,3 +93,31 @@ Crud component configuration.
.. note::

Ensure that you escape your namespace when loading your own action classes.

Using custom named controller actions
-------------------------------------

When using non CRUD named controller actions, like ``UsersController::drinkbeer()`` you can use one of the provided Crud Actions or create your own custom Action. Just assign the wanted action to the controller function:

.. code-block:: phpinline
class UsersController extends \Cake\Controller\Controller
{
use \Crud\Controller\ControllerTrait;
public function initialize()
{
parent::initialize();
$this->loadComponent('Crud.Crud', [
'actions' => [
'drinkbeer' => ['className' => '\App\Crud\Action\DrinkbeerAction']
]
]);
}
public function drinkbeer() {
$this->Crud->execute();
}

0 comments on commit c505400

Please sign in to comment.