Good morning everyone, in my plugin (version 5.2) i want to hook the getOneByUser method in AddressRepository.php.
I tried to use this code but the method AfterGetOneByUser() is never called:
/*
* File: custom/plugins/SwagMyAddreses/Subscriber/FrontendSubscriber.php
* called in the service.xml
*/
namespace SwagMyAddresses\Subscriber;
use Enlight_Hook_HookArgs;
use Shopware\Models\Customer\Address;
use Enlight\Event\SubscriberInterface;
class FrontendSubscriber implements SubscriberInterface
{
/**
* Return an array with the requested class names and the according callback functions
*
* @return array
*/
public static function getSubscribedEvents()
{
return array(
'Shopware\Models\Customer\AddressRepository::getOneByUser::after' => 'AfterGetOneByUser',
);
}
public function AfterGetOneByUser(\Enlight_Hook_HookArgs $arguments) {
//original builder
$builder = $arguments->getReturn();
//my $builder modifications ...
$arguments->setReturn($builder);
}
}
How should I modify my code to hook the getOneByUser, or just replace it entirely?
Thank you in advance.