2017 © Pedro Peláez
 

symfony-bundle object-route-bundle

Symfony M4nuObjectRouteBundle

image

m4nu/object-route-bundle

Symfony M4nuObjectRouteBundle

  • Monday, October 28, 2013
  • by EmmanuelVella
  • Repository
  • 1 Watchers
  • 5 Stars
  • 1 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

M4nuObjectRouteBundle

This Symfony2 bundle allows to create routes from an object instead of parameters., (*1)

Build Status, (*2)

How to install ?

Add theses lines into your deps

[M4nuObjectRouteBundle]
    git=git://github.com/M4nu/M4nuObjectRouteBundle.git
    target=/bundles/M4nu/ObjectRouteBundle

Add autoloading

#app/autoload.php
$loader->registerNamespaces(array(
    #...
    'M4nu' => __DIR__.'/../vendor/bundles',
));

Register this bundle

#app/AppKernel.php
$bundles = array(
    #...
    new M4nu\ObjectRouteBundle\M4nuObjectRouteBundle(),
);

Install the deps

php bin/vendors install

Examples

Let's say we have a Category and a Message object :, (*3)

$category = new Category();
$category->setSlug('my-category');

$message = new Message();
$message->setSlug('my-message');
$message->setCategory($category);

And the corresponding route :, (*4)

message_show:
    pattern:   /message/{category.slug}/{slug}

Create the corresponding route

$router->generate('message_show', $message);
{{ path('message_show', message) }}

Will output: /message/my-category/my-message, (*5)

Override parameters

$router->generate('message_show', array('_object' => $message, 'slug' => 'my-custom-slug'));
{{ path('message_show', {'_object': message, 'slug': 'my-custom-slug'}) }}

Will output: /message/my-category/my-custom-slug, (*6)

The Versions

28/10 2013

dev-refactoring

dev-refactoring

Symfony M4nuObjectRouteBundle

  Sources   Download

The Requires

 

by Emmanuel Vella

route object

28/10 2013

dev-master

9999999-dev

Symfony M4nuObjectRouteBundle

  Sources   Download

The Requires

 

by Emmanuel Vella

route object