Nisanth Kumar
Nisanth Kumar

Reputation: 5715

Use a controller in another one using zend

I have a controller for example "Price" also another one "Testprice" both using the same database table and the functionality are same only difference for "Testprice" the table have field test value true and for "Price" test = false . How can i extend the "Price" controller to this "Testprice" :)

Upvotes: 2

Views: 322

Answers (2)

Ivan Krechetov
Ivan Krechetov

Reputation: 19220

You can make Testprice forward to Price with a "test" parameter present.

$this->_forward('index', 'price', null, array('test' => 1));

And then check for "test" request parameter in the Price controller's index action

Another option is to configure the Zend router in your application.ini:

resources.router.routes.testprice.route = "testprice/"
resources.router.routes.testprice.defaults.controller = "price"
resources.router.routes.testprice.defaults.action = "testprice"

And it will call testpriceAction in the Price controller for /testprice/ URI

Upvotes: 3

Natrium
Natrium

Reputation: 31174

just use 1 class Price with a member Test, that you set tot true if you are using it as a test.

Upvotes: 1

Related Questions