在控制器中创建一个不是动作的函数是不好的做法吗?
例子:createCookie
下面Controller中的函数
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);
}