2017 © Pedro Peláez
 

library rad-url-generation

Simply auto-complete needed route parameters with existing ones.

image

knplabs/rad-url-generation

Simply auto-complete needed route parameters with existing ones.

  • Monday, February 5, 2018
  • by Knplabs
  • Repository
  • 20 Watchers
  • 5 Stars
  • 5,111 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 4 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

DEPRECATED

Unfortunately we decided to not maintain this project anymore (see why). If you want to mark another package as a replacement for this one please send an email to hello@knplabs.com., (*1)

Rapid Application Development : Url Generation

Simply auto-complete needed route parameters with existing ones., (*2)

Build Status Scrutinizer Code Quality Latest Stable Version Total Downloads Latest Unstable Version License, (*3)

Official maintainers:

Installation

composer require knplabs/rad-url-generation ~2.0
class AppKernel
{
    function registerBundles()
    {
        $bundles = array(
            //...
            new Knp\Rad\UrlGeneration\Bundle\UrlGenerationBundle(),
            //...
        );

        //...

        return $bundles;
    }
}

Usages

Just continue to use former url generation, nothing changes concerning the implementation. The only change is you don't repeat current route parameters anymore., (*4)

Example 1

Current route:, (*5)

app_products_show:
    path: /shops/{shop}/products/{products}/

My current url is /shops/12/products/345/. I want to build again the same url. Should I repeat route parameters if it already is my current route?, (*6)

Nope., (*7)

$router->generate('app_products_show');                                  // Returns /shops/12/products/345/
$router->generate('app_products_show', ['product' => 122]);              // Returns /shops/12/products/122/
$router->generate('app_products_show', ['shop' => 1]);                   // Returns /shops/1/products/345/
$router->generate('app_products_show', ['shop' => 1, 'product' => 122]); // Returns /shops/1/products/122/

Example 2

Current route:, (*8)

app_products_show:
    path: /shops/{shop}/products/{products}/

Current URL: /shops/1/products/122/, (*9)

I want to build this URL, (*10)

app_variant_show:
    path: /shops/{shop}/products/{products}/variants/{variant}/

I could execute:, (*11)

$router->generate('app_variant_show', ['shop' => 1, 'product' => 122, 'variant' => 23]); // Returns /shops/1/products/122/variants/23/

But why should I repeat already existing parameters ?, (*12)

$router->generate('app_variant_show', ['variant' => 23]); // Returns /shops/1/products/122/variants/23/

Works with

  • Router service : $container->get('router')->generate('app_products_show').
  • Controller shortcuts: $this->generateUrl('app_products_show') and $this->redirectToRoute('app_products_show').
  • Twig functions: path('app_products_show') or url('app_products_show').
  • Everything else using the Symfony router.

The Versions

05/02 2018

v1.x-dev

1.9999999.9999999.9999999-dev

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

05/02 2018

v1.0.3

1.0.3.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

21/09 2017

dev-master

9999999-dev

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

21/09 2017

v2.1.0

2.1.0.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

03/03 2016

v2.0.0

2.0.0.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

29/04 2015

v1.0.2

1.0.2.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

11/03 2015

v1.0.1

1.0.1.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion

11/03 2015

v1.0.0

1.0.0.0

Simply auto-complete needed route parameters with existing ones.

  Sources   Download

MIT

The Requires

 

The Development Requires

url routing router uri rad autocompletion