(Yaf >=1.0.0)
Yaf_Application::app — Retrieve an Application instance
Retrieve the Yaf_Application instance. Alternatively, Yaf_Dispatcher::getApplication() can also be used.
У цієї функції немає параметрів.
The Yaf_Application instance, or null if no
application has been initialized yet.
Приклад #1 Yaf_Application::app() example
<?php
/* index.php, the application entry */
$config = new Yaf_Config_Ini(__DIR__ . "/conf/application.ini", "product");
$application = new Yaf_Application($config);
$application->bootstrap()->run();
?>Приклад #2 Retrieving the application instance elsewhere
<?php
class IndexController extends Yaf_Controller_Abstract
{
public function indexAction()
{
/* Yaf_Application::app() is an alias of getInstance() */
$app = Yaf_Application::app();
var_dump($app->environ());
var_dump(Yaf_Application::getInstance() === $app);
return false;
}
}
?>Поданий вище приклад виведе щось схоже на:
string(7) "product" bool(true)