在不是動作的控制器中創建函數是不好的做法嗎?不是控制器中的動作的Zend Framework函數
例如:在下面的控制器
protected $translator;
protected $cookie;
public function __construct($translator, $cookie)
{
$this->translator = $translator;
$this->cookie = $cookie;
}
public function changeLanguageAction()
{
$language = $this->params()->fromRoute('lang', 'en');
$this->createCookie('xuage', $language, '/');
$this->getResponse()->getHeaders()->addHeader($this->cookie);
$this->redirect()->toRoute('home');
}
public function createCookie($name, $value, $path)
{
$this->cookie->setName($name);
$this->cookie->setValue($value);
$this->cookie->setPath($path);
}