# 5.2 Plugin: hook AddressRepository

**URL:** https://forum.shopware.com/t/5-2-plugin-hook-addressrepository/40536
**Category:** International (English Only)
**Tags:** programming
**Created:** [14. Oktober 2016 um 08:59 UTC](https://forum.shopware.com/t/5-2-plugin-hook-addressrepository/40536 "2016-10-14T08:59:15Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![\_Elena](https://avatars.discourse-cdn.com/v4/letter/_/d07c76/32.png) [@\_Elena](https://forum.shopware.com/u/_Elena)
#### Post date: [14. Oktober 2016 um 08:59 UTC](https://forum.shopware.com/t/5-2-plugin-hook-addressrepository/40536/1 "2016-10-14T08:59:15Z")

</div>

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?  
&nbsp;

Thank you in advance.
