eko / FeedBundle

A Symfony bundle to build RSS feeds from your entities
http://vincent.composieux.fr
MIT License
141 stars 49 forks source link

dynamic route_params? #61

Closed yndlingsfar closed 8 years ago

yndlingsfar commented 8 years ago

Hi, is there any possibility to configure dynamic route_params? e.g. I have the following use case:

URL: /order/12345/delivery (where 12345 represents an unique order number) should return the following ATOM feed:

` <?xml version="1.0" encoding="utf-8"?>

``` order/delivery-feed xxx 2016-09-05T09:45:25+02:00 /order/12345/delivery xxx ```

`

The issue is, that in config.yml I can only configure static routing params, e.g

link: route_name: order_delivery route_params: id: xyz

And this would result in

<link href="/order/xyz/delivery" rel="self" type="application/rss+xml"/>

Please tell me, how can I inject the order number 12345 into the feed itself?

BR

Daniel

eko commented 8 years ago

Hi @dsteiner23,

Have you tried to use Expression Language? http://symfony.com/doc/master/service_container/expression_language.html

It should be something like this:

link:
    route_name: order_delivery
    route_params:
        id: "@=service('your_service').getMyValue()"

I hope it helps.

Thank you

yndlingsfar commented 8 years ago

I could solve the problem programmatically.

` $feed = $this->feedManager->get("atom")->addFromArray($view->getData()); $feed->set('link', [

        'route_name' => 'order_delivery',
        'route_params' => [
            'id' => $order->getId()

        ]);

`

eko commented 8 years ago

@dsteiner23 Great, thank you for your explanations!