Пример #1
0
$userProfileController = new UserProfileController($userProfileView);
$settingsController = new SettingsController($settingsView, $settingsModel);
$mainController = new MainController($registerController, $loginController, $searchController, $userProfileController, $settingsController, $layoutView, $settingsView);
$mainController->listen();
// What view to render within LayoutView
if ($mainController->renderRegView()) {
    $layoutView->render(false, $registerView);
} else {
    if ($mainController->renderSearchView()) {
        if ($searchModel->foundMatch()) {
            $layoutView->render($loginModel->isLoggedIn(), $userProfileView);
        } else {
            $layoutView->render($loginModel->isLoggedIn(), $searchView);
        }
    } else {
        if ($mainController->renderSettingsView()) {
            $layoutView->render($loginModel->isLoggedIn(), $settingsView);
        } else {
            if ($mainController->renderMyProfile()) {
                $layoutView->render($loginModel->isLoggedIn(), $userProfileView);
            } else {
                if ($loginModel->isLoggedIn()) {
                    $userProfileView->setUser(null);
                    $layoutView->render($loginModel->isLoggedIn(), $userProfileView);
                } else {
                    $layoutView->render($loginModel->isLoggedIn(), $loginView);
                }
            }
        }
    }
}