Предполагая, что плагин называется "test", вы можете сделать что-то подобное в app / plugins / test / controller / test_controller.php:
<?php
class TestController
extends AppController
{
public function index()
{
// Is there any additional args passed to us?
if(count($this->passedArgs) > 0)
{
// Is this a request for one of our actions?
$actualAction = $this->passedArgs[0];
if(is_callable(array($this, $actualAction)))
{
// Yup. Do it.
return call_user_func_array(array($this, $actualAction), array_slice($this->passedArgs, 1));
}
}
// Default functionality here.
die("Index of plugin requested.");
}
public function another($param1, $param2)
{
die("{$param1}, {$param2}");
}
}
Вам также необходимо добавить следующее в app / config / rout.php:
Router::connect("/test/*", array("plugin" => "test", "controller" => "test"));
После этого запрос к / test / another / one / two будет правильно отображать «один, два» в браузере, а запрос к / test будет отображать «Индекс запрошенного плагина».
Я думаю, что это не плохой путь, минимальная суета на стороне потребителя плагина, только небольшая ошибка в коде плагина.