
Yaf_Controller_Abstract의 initView 메서드는 뷰를 초기화하는 역할을 합니다. 이 메서드는 _initView() 메서드를 호출하여 뷰를 초기화합니다.
initView 메서드는 파라미터를 받지 않습니다.
initView 메서드는 뷰를 초기화하는 과정을 진행하는 데, 다음의 순서를 따른다.
1. 뷰의 기본 경로를 설정합니다.
2. 뷰의 확장자를 설정합니다.
3. 뷰의 이름을 얻어냅니다.
4. 뷰를 초기화합니다.
initView 메서드는 뷰를 초기화하는 과정을 진행하는 데, Yaf_View_Abstract 클래스의 render 메서드를 호출하여 뷰를 초기화합니다.
예를 들어, 다음과 같이 initView 메서드를 호출하여 뷰를 초기화할 수 있습니다.
#hostingforum.kr
php
class MyController extends Yaf_Controller_Abstract
{
public function init()
{
$this->initView();
}
public function initView()
{
$this->view->assign('title', 'My Title');
$this->view->assign('message', 'Hello, World!');
return $this->view->render('index.phtml');
}
}
2025-05-04 01:42