# Eigenes Plugin mit URL rewrite

**URL:** <https://forum.shopware.com/t/eigenes-plugin-mit-url-rewrite/29858>\
**Category:** Programmierung\
**Created:** [23. August 2015 um 16:34 UTC](https://forum.shopware.com/t/eigenes-plugin-mit-url-rewrite/29858 "2015-08-23T16:34:30Z")\
**Posts on this page:** 1\
**Showing post:** 4

<div class="post-metadata">

**Author:** ![Heiner\_Lohaus](https://avatars.discourse-cdn.com/v4/letter/h/b5a626/32.png) [@Heiner\_Lohaus](https://forum.shopware.com/u/Heiner_Lohaus)\
**Post date:** [14. Oktober 2015 um 16:38 UTC](https://forum.shopware.com/t/eigenes-plugin-mit-url-rewrite/29858/4 "2015-10-14T16:38:44Z")

</div>

Ja, ein Beispiel kannst du bekommen: 🙂 engine/Shopware/Plugins/Community/Frontend/SwagSeoRoutes/Bootstrap.php [code]\<?php use \Shopware\Components\Routing\Generators\RewriteGenerator;

/\*\*

- @category Shopware
- @package Shopware\Plugins\SwagSeoRoutes
- @copyright Copyright © shopware AG ([http://www.shopware.de](http://www.shopware.de))  
_/  
class Shopware\_Plugins\_Frontend\_SwagSeoRoutes\_Bootstrap extends Shopware\_Components\_Plugin\_Bootstrap  
{  
/_\*
  - @return bool  
\*/  
public function install()  
{  
$this-\>subscribeEvent( ‘Enlight\_Controller\_Front\_RouteStartup’, ‘onRouteStartup’ ); return true; } /\*\* \* @param Enlight\_Controller\_EventArgs $args \*/ public function onRouteStartup($args) { /\*\* @var \Shopware\Components\Routing\Router $router \*/ $router = $this-\>get(‘router’); $generators = $router-\>getGenerators(); $generators = array\_map(function($generator) { if($generator instanceof RewriteGenerator) { return new NewRewriteGenerator( $this-\>get(‘dbal\_connection’), $this-\>get(‘query\_alias\_mapper’) ); } else { return $generator; } }, $generators); $router-\>setGenerators($generators); } } class NewRewriteGenerator extends RewriteGenerator { protected function getOrgQueryArray($query) { $orgQuery = [‘sViewport’ =\> $query[‘controller’]]; switch ($query[‘controller’]) { case ‘meinPlugin’: $orgQuery[‘action’] = $query[‘action’]; $orgQuery[‘groupid’] = $query[‘groupid’]; $orgQuery[‘id’] = $query[‘id’]; return $orgQuery; default: return parent::getOrgQueryArray($query); } } }[/code] Das ist aber noch nicht ganz optimal. Es wäre ja schön, wenn man weitere Routen ohne extra Plugin hinzufügen kann. Vielleicht hast du ja eine Idee? Gruß Heiner

---

_[View the full topic](https://forum.shopware.com/t/eigenes-plugin-mit-url-rewrite/29858)._
