Abstract class Extension

i need to extend


namespace SilverShop\Checkout\Component;

use SilverShop\Model\Order;
use SilverShop\ShopUserInfo;
use SilverStripe\Core\Config\Config;
use SilverStripe\Forms\CompositeField;
use SilverStripe\Forms\FieldList;
use SilverStripe\ORM\DataObject;
use SilverStripe\Security\Security;
use SilverStripe\SiteConfig\SiteConfig;

abstract class Address extends CheckoutComponent

of SilverShop module
to modify method

public function setData(Order $order, array $data) 

i tried using

use SilverShop\Checkout\Component\Address as BaseAddress;
use SilverShop\Model\Order;
use SilverStripe\Core\Injector\Injectable;

class AddressExtension extends BaseAddress

and then in yml:

    class: Components\AddressExtension

i tried withd extends DataExtension too, without luck.

all other classes workings good.

Phpstorm with xdebug enter alwayin in original method.

Can you help me?

I’m assuming there’s some class (or multiple classes) which are subclasses of Address which you want to use your custom implementation of the setData method?

Since class inheritance is a PHP built-in feature and not part of Silverstripe CMS, the injector can’t be used to do what you want in the way you’re trying to use it. We can’t intercept the inheritance like that.

I took a look at what I think is the Address class source code and it doesn’t seem to have a setData method… where are you seeing that method?

In any case, you could do one of the following:

  • Make a subclass of each subclass of Address, and use injector to replace them
  • Use an Extension class (if there is an extension hook you can use)

Thank you for your suggestion,
I’ll try as you say.