Skip to content

Instantly share code, notes, and snippets.

@weaverryan
Created May 8, 2015 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weaverryan/0c41a49aafaad47459cf to your computer and use it in GitHub Desktop.
Save weaverryan/0c41a49aafaad47459cf to your computer and use it in GitHub Desktop.
Possible Doctrine Param Converter
<?php
class PostController
{
/**
* @Route("/posts/{slug}")
* @DoctrineParam("post", expr="repository.findOneBySlug(slug)")
*/
public function showAction(Post $post)
{
}
}
<?php
/**
* Maybe have a more global way of doing this to?
*
* @DoctrineParamNamed("find_by_slug", expr="repository.findOneBySlug(slug)")
*/
class PostController
{
/**
* @Route("/posts/{slug}")
* @DoctrineParam("post", convert_with="find_by_slug")
*/
public function showAction(Post $post)
{
}
}
@ifdattic
Copy link

ifdattic commented May 9, 2015

Looks good :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment