# \[Gelöst\] Decorate Service / Namespace Verständnis-Frage

**URL:** https://forum.shopware.com/t/gelost-decorate-service-namespace-verstandnis-frage/46873
**Category:** Programmierung
**Created:** [12. Juli 2017 um 14:02 UTC](https://forum.shopware.com/t/gelost-decorate-service-namespace-verstandnis-frage/46873 "2017-07-12T14:02:24Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![wingover](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wingover](https://forum.shopware.com/u/wingover)
#### Post date: [12. Juli 2017 um 14:02 UTC](https://forum.shopware.com/t/gelost-decorate-service-namespace-verstandnis-frage/46873/1 "2017-07-12T14:02:24Z")

</div>

Hallo zusammen,

ich habe eine Verständnis-Frage zu Namespaces, speziell bei einem dekorierten Service.

Und zwar habe ich ProductSearch dekoriert, das funktioniert soweit auch wunderbar:

```
namespace MyPlugin\Bundle\SearchBundle;

use Shopware\Bundle\SearchBundle;
use Shopware\Bundle\StoreFrontBundle;
use Shopware\Bundle\SearchBundle\ProductSearch;
use Shopware\Bundle\SearchBundle\ProductSearchInterface;

class MyProductSearch implements ProductSearchInterface
{
    private $productSearch;

    public function __construct(ProductSearchInterface $productSearch)
    {
    	$this->productSearch = $productSearch;
    }
	
    public function search(SearchBundle\Criteria $criteria, StoreFrontBundle\Struct\ProductContextInterface $context)
    {
    	return $this->productSearch->search($criteria, $context);
    }
}

```

Wenn ich allerdings search mit absoluten Namespaces und ohne den ersten beiden ‘use’ aufrufe, bekomme ich eine Fehlermeldung:

Declaration of …MyProductSearch::search() must be compatible with Shopware\Bundle\SearchBundle\ProductSearchInterface::search(Shopware\Bundle\SearchBundle\Criteria $criteria, Shopware\Bundle\StoreFrontBundle\Struct\ProductContextInterface $context)

```
public function search(Shopware\Bundle\SearchBundle\Criteria $criteria, Shopware\Bundle\StoreFrontBundle\Struct\ProductContextInterface $context)

```

Sollte das nicht auch funktionieren?

Viele Grüße

Andi

---

<div class="post-metadata">

### Author: ![simkli](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/simkli/32/13124_2.png) [@simkli](https://forum.shopware.com/u/simkli)
#### Post date: [12. Juli 2017 um 14:03 UTC](https://forum.shopware.com/t/gelost-decorate-service-namespace-verstandnis-frage/46873/2 "2017-07-12T14:03:54Z")

</div>

Hi Andi,

ja tut es wenn du ganz am Anfang noch einen Backslash hinzufügst&nbsp; ![Wink](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/b3785da0cbf2c8566cb535dcf55b2730b5224899.png "Wink")

```
public function search(\Shopware\Bundle\SearchBundle\Criteria $criteria, \Shopware\Bundle\StoreFrontBundle\Struct\ProductContextInterface $context)
    {
        // ...
    }

```

Viele Grüße

---

<div class="post-metadata">

### Author: ![wingover](https://avatars.discourse-cdn.com/v4/letter/w/65b543/32.png) [@wingover](https://forum.shopware.com/u/wingover)
#### Post date: [12. Juli 2017 um 14:22 UTC](https://forum.shopware.com/t/gelost-decorate-service-namespace-verstandnis-frage/46873/3 "2017-07-12T14:22:59Z")

</div>

Super, vielen Dank für den Hinweis ![Smile](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/1X/bac5f5766b6a20565a8fb995345b4e41d24daac0.png "Smile")

Den Backslash habe ich total übersehen, bzw. vergessen…

Viele Grüße

Andi
