我可以将参数发送到控制器在Kohana中的操作吗?

时间:2021-06-30 10:56:30

Shouldn't I? Is it considered bad practice? If so, why?

不应该吗?这被认为是不好的做法吗?如果是这样,为什么?

For ex:

例如:

    public function action_index($err='', $success='')
    {
        $priorities = Model::factory('Priorities')->get_all();
        $this->template->content = View::factory("admin/priorities/list.tpl", array('rows' => $priorities, 'error' => $err));
    }

UPD: Why do I ask? Controller Parameters deprecated in one framework

UPD:我为什么要问?控制器参数在一个框架中已弃用

2 个解决方案

#1


1  

According to the documentation, the answer is: no.
Instead you should be using $this->request within the "controller" to access the user input.

根据文档,答案是:不。相反,您应该在“控制器”中使用$ this-> request来访问用户输入。

As for "what data is contained there", you should consult the code for the instantiation of Request, that can be found here.

至于“那里包含什么数据”,你应该查阅Request的实例化代码,可以在这里找到。

#2


-2  

Yes, you can pass it. i'm doing it in CODEIGNITER.

是的,你可以通过它。我在CODEIGNITER中这样做。

#1


1  

According to the documentation, the answer is: no.
Instead you should be using $this->request within the "controller" to access the user input.

根据文档,答案是:不。相反,您应该在“控制器”中使用$ this-> request来访问用户输入。

As for "what data is contained there", you should consult the code for the instantiation of Request, that can be found here.

至于“那里包含什么数据”,你应该查阅Request的实例化代码,可以在这里找到。

#2


-2  

Yes, you can pass it. i'm doing it in CODEIGNITER.

是的,你可以通过它。我在CODEIGNITER中这样做。