关于 symfony 中的操作
在我的网站上,我有一个小组部分。这些组有活动、论坛等。我使用 symfony 并且有以下文件:
class GroupActions extends sfActions{
public function preExecute(){
$request = $this->context->getRequest();
$this->group = fGroup::getGroupById($request->getRequestParameter('id_group'));
//Group security
$this->group_security = $this->group->getSecurity();
//More required actions about groups
....
}
class ForumActions extends GroupActions {
public function preExecute() {
parent::preEcecute();
$this->forum = $this->group->getForums();
}
ForumActions 扩展了 GroupActions 因为我需要组数据。例如,请求:
/groups/2/forum
转发到ForumActions,我可以获取组的数据。
这是正确的吗?
谢谢。
In my website I have a section of groups. The groups have events, forum, etc. I use symfony and I have the following files:
class GroupActions extends sfActions{
public function preExecute(){
$request = $this->context->getRequest();
$this->group = fGroup::getGroupById($request->getRequestParameter('id_group'));
//Group security
$this->group_security = $this->group->getSecurity();
//More required actions about groups
....
}
class ForumActions extends GroupActions {
public function preExecute() {
parent::preEcecute();
$this->forum = $this->group->getForums();
}
ForumActions extends GroupActions because I need group data. For example, the request:
/groups/2/forum
forwards to ForumActions and I can get group's data.
Is this correct?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在这里,我认为这里有一个错误:
它应该是:
也许这就是你最终得到一个空的组信息的方式。另外,在操作中定义类变量,然后在某种方法中初始化它们(getter 和 setter 也可以提供帮助)始终是一种惯例,这样您就可以确保其他可能需要它们的变量可以被访问。
Here there, i think there is a mistake here where it says:
And it should be:
Maybe that is way you ended up with an empty group info. Also, its always a got practice to define your class variables in the action and then initialize them in some method (also getters and setters could help.) so you assure that variables could be reached be others that might need them.