genj/frontend-url-bundle

This package is abandoned and no longer maintained. No replacement package was suggested.

Symfony Frontend Url bundle - Provides helpers to easily generate URLs for frontend routes from within an admin environment.

Installs: 4 151

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 4

Forks: 2

Open Issues: 0

Type:symfony-bundle

v1.0.0 2015-08-09 09:03 UTC

This package is not auto-updated.

Last update: 2024-02-17 13:02:21 UTC


README

Provides helpers to generate frontend URLs. Your Entities need these methods in order for this bundle to work:

    public function getRouteName()
    {
        return 'genj_article_article_show';
    }

    public function getRouteParameters()
    {
        return array(
            'categoryType' => $this->getCategory()->getType(),
            'categorySlug' => $this->getCategory()->getSlug(),
            'slug'         => $this->getSlug()
        );
    }	

Configuration

You must set the name of your frontend environment in config.yml:

genj_frontend_url:
    frontend_environment: my_frontend_app

Usage

Front-end URL generation

From twig:

{{ object|genj_url_for_frontend }}

From PHP:

$urlGenerator = $this->container->get('genj_url_generator.routing.frontend.generator.url_generator');
$frontendUrl  = $urlGenerator->generateFrontendUrlForObject($object);

Preview parameter

It is possible to generate a URL to a 'preview controller'. You could e.g. restrict access to that controller and show non-cached versions of certain pages. If you do:

$frontendUrl  = $urlGenerator->generateFrontendUrlForObject($object, true);

Then the resulting URL would become /preview.php/path/to/page.

You can use the same thing from Twig too:

{{ object|genj_url_for_frontend(true) }}

More about environments: http://symfony.com/doc/current/cookbook/configuration/environments.html