Skip to content
This repository was archived by the owner on Feb 14, 2024. It is now read-only.

genj/GenjFrontendUrlBundle

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GenjFrontendUrlBundle

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

About

Provides helpers to easily generate URLs for frontend routes from within an admin environment.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors