prepend new route to routelist

Notice: This thread is very old.
bauer01
Member | 30
+
0
-

I'd like to generate some routes in my compiler extension automatically. They should be inserted before all defined routes in router service, but there is a problem with RouteList class because it implements ArrayAccess which is not compatible with array_unshift. Any idea how to solve it? Maybe add new function prepend() to Nette\Utils\ArrayList?

MyCompilerExtension.php

public function beforeCompile()
{
    $builder = $this->getContainerBuilder();
    $builder->getDefinition("router")->addSetup('$service[] = MyCustomRouterFactory::create');
}
jiri.pudil
Nette Blogger | 1028
+
+1
-

You can take a look at how Kdyby solves this. It's not much elegant, but it works.

bauer01
Member | 30
+
0
-

nice, that's enough, thx