S
S
Sergey Pugovkin2017-03-27 15:08:52
Yii
Sergey Pugovkin, 2017-03-27 15:08:52

How to display headers, content (string) in a component and correctly terminate the application?

1. How to display headers, content (string) in a component and correctly terminate the application?
2. How about a redirect?
The component is used as BeforeController (i.e. it is registered in the config in the bootstrap parameter and in the init of the component we already write what needs to be done before calling the controller). Depending on the requested domain name, you need to take certain actions and not launch the main site.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Maxim Timofeev, 2017-03-27
@Driver86

Why not?

class Controller extends MainController {
public function beforeAction($action)
{
    if (!parent::beforeAction($action)) {
        return false;
    }

     if (!isset($_GET['user'])){
        return $this->redirect('index');
    } 

    return true; 
}}

www.yiiframework.com/doc-2.0/yii-base-controller.h...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question