I just want to call my controller function in another controller using kohana. Here i am attached what i tried.
我只想使用kohana在另一个控制器中调用我的控制器功能。在这里,我依附于我所尝试的。
$file = Reports_Controller::getpdf($reportname, $model);
$ file = Reports_Controller :: getpdf($ reportname,$ model);
1 个解决方案
#1
1
You should make internal Request.
你应该提出内部请求。
<?php
class Controller_Report extends Controller {
// report/get_pdf
public function action_get_pdf()
{
echo 'echo PDF here!';
}
}
class Controller_Page extends Controller {
public function action_index()
{
$response = Request::factory('report/get_pdf')
->method('GET')
->query($data) // or ->post($data)
->execute();
$response->status(); // 404 or 200 etc
$response->headers();
$response->body();
}
}
#1
1
You should make internal Request.
你应该提出内部请求。
<?php
class Controller_Report extends Controller {
// report/get_pdf
public function action_get_pdf()
{
echo 'echo PDF here!';
}
}
class Controller_Page extends Controller {
public function action_index()
{
$response = Request::factory('report/get_pdf')
->method('GET')
->query($data) // or ->post($data)
->execute();
$response->status(); // 404 or 200 etc
$response->headers();
$response->body();
}
}