Symfony 1.4 is already a legacy framework. But I think a lot of web system still running on it. In this post, I will show you some quick tips for accessing infromation by using sfContext . sfContext provides almost everything you want access. But you should not use context everywhere too much because sfContext is a kind of global objeect and if a lot of codes depends on context, your code will be hard to be tested or maintained, I think. Basic You can access sfContext by following code. sfContext::getInstance(); In sfFilter, you can access sfContext by the following code. $this->getContext(); What Kind of Fields You can access? Routing name $context->getRouting()->getCurrentRouteName(); User $context->getUser(); Request $context->getRequest(); Response $context->getResponse(); Controller $context->getController(); Logger sfContext::getInstance()->getLogger(); Advanced Use Check if http request is secure (e.g. https request). $co...
IT関連の技術やプログラミングを中心に記事を書いています。ハードウェアも好きなので、日々のちょっとしたお役立ち情報も投稿しています。