Jeroen Minnaert
Jeroen Minnaert

Reputation: 645

Is there a way to have multiple controllers for a symfony 1.4 module?

I have a situation where I have a base controller (a base actions.php file) in Symfony 1.4. I want to create another controller, for the same module, that extends that base controller.

I need to extend that base controller because I want to customize the behavior of certain visitors, that are identified based on an ID in the URL.

Any hints?

Upvotes: 0

Views: 596

Answers (2)

botero
botero

Reputation: 596

Actually you can add another controller class for the same module.

You could include several files in your action directory in this way:

In action1Action.class.php

class action1Action extends sfAction
{
    public function execute($request) {
        //Your code here
    }
}

This will use template action1Success.php

In action2Action.class.php

class action2Action extends sfAction
{
    public function execute($request) {
        //Your code here
    }
}

This will use template action2Success.php

Upvotes: 0

glerendegui
glerendegui

Reputation: 1507

Another controller class for the same module, I think it's impossible in symfony.

I guess the easiest solution for you is to create another method in the same class, and then invoque it from the base one.

By Example: actions.class.php:

public function executeBaseAction(sfWebRequest $request) {

   .. if($user....) then return $this->executeCustomAction($request);

}

public function executeCustomAction(sfWebRequest $request) {
  // $this->setTemplate('anotherTemplate?');

}

Upvotes: 1

Related Questions