1998 Posts in 530 Topics by 433 members
E-Commerce Modules
SilverStripe Forums » E-Commerce Modules » Extending CheckoutPage_Controller
Discuss about the various e-commerce modules available:
Ecommerce, SS Shop, SilverCart and SwipeStripe
Alternatively, have a look the shared mailinglist.
Moderators: martimiz, Nicolaas, Howard, Sean, Ryan M., biapar, Willr, Ingo, Jedateach, swaiba, simon_w
|
Page:
1
|
Go to End | |
| Author | Topic: | 757 Views |
-
Extending CheckoutPage_Controller

20 October 2009 at 2:27am
Hi
I need to add an extra action to the CheckoutPage_Controller class. I want to do this in a way that does not change any module code so that I can easily update the module at a later date.
I have been able to achieve this by adding my action method into the Page_Controller class which CheckoutPage_Controller inherits from, but this is a little messy for me as that action will now be available on all controllers that inherit from Page_Controller.
Is there a way to use the Decorator pattern to achieve the same thing. I have tried using the Extension class, and although I know the class is being hooked in (overrode the setOwner method to check) the new action Method is not allowed.
placed in mysite/_config.php
Object::add_extension('CheckoutPage_Controller','ExtendedCheckoutPage_Controller');
class ExtendedCheckoutPage_Controller extends Extension {
function LocalOrderForm() {
return new LocalOrderForm($this->owner, 'LocalOrderForm');
}
}Anyone got any advice here?
Many thanks
Jason -
Re: Extending CheckoutPage_Controller

14 November 2009 at 12:39am
The Extension Class has to look the Following:
class ExtendedCheckoutPage_Controller extends Extension {
public static $allowed_actions = array('LocalOrderForm');
function LocalOrderForm() {
return new LocalOrderForm($this->owner, 'LocalOrderForm');
}}
That worked for me on extending the Polls Module.
Greetings
Andre
-
Re: Extending CheckoutPage_Controller

14 November 2009 at 1:11am
Thanks Andre
I will have a go with that, makes sense though.
Cheers
Jason
| 757 Views | ||
|
Page:
1
|
Go to Top |


