
Yaf_Router::getCurrentRoute 메소드는 현재 라우트 정보를 얻기 위해 사용됩니다. 하지만 Zend_Controller_Front::getInstance()->getRouter()를 사용하여 라우터 객체를 가져올 때 오류가 발생하는 이유는 Zend Framework가 아닌 Yaf 프레임워크를 사용하고 있기 때문입니다.
Yaf 프레임워크에서는 라우터 객체를 가져올 때 Yaf_Application::getInstance()->getDispatcher()->getRouter()를 사용해야 합니다.
올바른 코드는 다음과 같습니다.
#hostingforum.kr
php
$router = Yaf_Application::getInstance()->getDispatcher()->getRouter();
$route = $router->getCurrentRoute();
또한, Yaf_Router::getCurrentRoute 메소드는 현재 라우트 정보를 얻기 위해 사용됩니다. 하지만 라우트 정보가 없을 때 오류가 발생할 수 있습니다. 따라서 라우트 정보가 없을 때 예외 처리를 해주어야 합니다.
#hostingforum.kr
php
$router = Yaf_Application::getInstance()->getDispatcher()->getRouter();
$route = $router->getCurrentRoute();
if ($route !== null) {
// 라우트 정보가 존재할 때
} else {
// 라우트 정보가 존재하지 않을 때
}
2025-07-25 03:02