About actions in symfony
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 funct开发者_运维知识库ion 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.
Here there, i think there is a mistake here where it says:
$this->group = fGroup::getGroupById($request->getRequestParameter('id_group'));
And it should be:
$this->group = fGroup::getGroupById($request->getParameter('id_group'));
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.
精彩评论