Mick
Mick

Reputation: 31919

Embed a controller within a template

We can easily embed a controller within a template in twig:

{% render "AcmeGolferBundle:Golfer:showGolfersList" %}

When we basically use a controller like this:

 /**
 * Lists all golfers.
 *
 * @Route("/golfersList", name="golfers_list")
 * @Template()
 */
public function showGolfersListAction()
{
    //....doStuff
}

In that case, the only use of the controller will be in that template. Is there a way to avoid the user to trigger the url directly, meaning /golferList on its own?

EDIT

The point I am trying to make is the following: I need the user to use the controller through the template it is embedded in, but not directly via the url. I realise this might not be possible, but because the controller is embedded, it doesn't have a proper css structure. Therefore, if it is triggered via the url directly, it will look pretty ugly on the page.

Upvotes: 1

Views: 580

Answers (1)

Vitalii Zurian
Vitalii Zurian

Reputation: 17976

Securing route by IP might be useful for you:

security: 
    # ...
    access_control:
        - { path: ^/golferList, roles: IS_AUTHENTICATED_ANONYMOUSLY, ip: 127.0.0.1 }

Upvotes: 2

Related Questions