| モジュール/コントローラ | ファイルパス | クラス名 |
|---|---|---|
| index/index | app/index/controllers/Index.php | Index_Controllers_Index |
| index/fooBar | app/index/controllers/FooBar.php | Index_Controllers_FooBar |
| manage/main | app/manage/controllers/Main.php | Manage_Controllers_Main |
| manage/fooBar | app/manage/controllers/FooBar.php | Manage_Controllers_FooBar |
app/index/controllers/Index.php
<php
class Index_Controllers_Index extends Sabel_Controller_Page
{
public function index()
{
$this->inputValue = $this->request->fetchGetValue("input");
}
}
app/index/views/index/index.tpl
<p>
<?php if (is_empty($inputValue)) : ?>
値が入力されませんでした。
<?php else : ?>
入力された値は「<?php echo h($inputValue) ?>」です。
<?php endif ?>
</p>
http://.../index/index?input=test のようにアクセスすれば、"入力された値は「test」です。" と表示されます。
class Index_Controllers_Index extends Sabel_Controller_Page
{
public function myAction1()
{
$this->commonLogic();
}
public function myAction2()
{
$this->commonLogic();
}
protected function commonLogic()
{
// 共通の処理
}
}
上記のコントローラにおいて、/index/myAction1 や /index/myAction2 でアクセスされた時は各アクションが実行されますが、/index/commonLogic にアクセスしてもcommonLogic()メソッドが実行されることはありません。