Enable PropelParamConverter to find on ->getName() #154

Closed
wants to merge 1 commit into
from

4 participants

@cedriclombardot

This make easiest Param conversion for esi

<?php

/**
  * @ParamConverter("book", class="MyCoreBundle:Model:Core:Book")
  */
    public function renderAction(Book $book)
    {
        return $this->render('....', array(
            'book' => $book,
        ));
    }
@cedriclombardot cedriclombardot Enable PropelParamConverter to find on ->getName()
This make easiest Param conversion for esi
73aa53c
@travisbot

This pull request passes (merged 73aa53c into 2387821).

@willdurand
Propel member

I think I don't understand the purpose of this feature... can you elaborate a bit more?

@cedriclombardot

For my controller the esi internal url generated look like :

frontend_dev.php/_internal/secure/my.core.block.list%3ArenderAction/ block%3D1 .html

And my controller look like :

    /**
     * Render a block
     *
     * @ParamConverter("block", class="XXXXCoreBundle:Model:Core:Block")
     *
     * @param Block $block
     */
    public function renderAction(Block $block)
    {
        ///
    }

Or actually the paramConverter try to find by the object $block using the id parameter or a findOnByBlock but not a findById($_GET['block']) that what enabled the PR

@willdurand
Propel member

I still don't get the point, but let's wait for @jaugustin's work on the converter.

@jaugustin
Propel member

To do that, your parameter should be named "id" (in your request)

@cedriclombardot

Yes but my problem is thats not my url but the symfony _internal for ESI

@jaugustin
Propel member

I don't know how symfony handle internal route for ESI, does doctrineParamConverter handle it the right way ?

@jaugustin
Propel member

after our talk I think the right way to use PropelParamConverter with ESI is the same as with normal route :

set parameter : id => $book->getId()
or : slug => $book->getSlug() if you have a filterBySlug in the query class

what you want could be understanded as a mapping option:

<?php

/**
 * @ParamConverter("book", class="Model\Book", options={"mapping" : { "routeParam1" : "id"} })
 * @ParamConverter("author", class="Model\Author", options={"mapping" : { "routeParam2" : "slug"} })
 */
public function myAction(Book $book, Author $author)
{ }
@willdurand
Propel member

Ok, I'm closing it.

@willdurand willdurand closed this May 24, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment