-2
class examController{
public function regMail(){
}
}
我想在authController
class authController{
// i want regMail() here
}
class examController{
public function regMail(){
}
}
我想在authController
class authController{
// i want regMail() here
}
調用regMail()來這樣做,你有2個解決方案:
1 - 使用forwarding(良好做法);
//In your controllor
public function indexAction($name) {
$response = $this->forward('AppBundle:Something:fancy', array(
'name' => $name,
'color' => 'green',
));
// ... further modify the response or return it directly
return $response;
}
2 - 將您的控制器定義爲服務(壞習慣);
嘗試看看這個post瞭解更多細節和(當然)官方文檔。 祝你好運^^!
控制器應包含操作。發送郵件看起來像是一項服務的工作。 http://symfony.com/doc/current/book/service_container.html –
把你的動作改爲模態,然後從控制器調用它 – Poria
你應該看看文檔,並嘗試瞭解如何使用服務以及服務是什麼容器由Symfony提供。 – COil