Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow iterating over a collection to generate links #35

Open
baldurrensch opened this issue Mar 5, 2013 · 8 comments
Open

Allow iterating over a collection to generate links #35

baldurrensch opened this issue Mar 5, 2013 · 8 comments

Comments

@baldurrensch
Copy link
Contributor

We should be able to generate links off of collections, so you would specify a parameter to create a link for each element in that array.

For example, you have an array of authors, and you want to generate a link for each author

/**
 * @Rest\Relation("self",      
 *   href = @Rest\Route("author", collection_parameters = { "id" = ".author[].id" }))
 */
@adrienbrault
Copy link
Contributor

What about something like

@RelationCollection(
    @Relation("author", href = @Route("user_get", "parameters" = { "id" = "id" })),
    "property" = "author"
)

or

@Relations(
    @Relation("author", href = @Route("user_get", "parameters" = { "id" = "id" })),
    "property" = "author"
)

@baldurrensch
Copy link
Contributor Author

Yeah. I like that. Now, the problem is: The id is with respect to author. What if you want to have a variable with respect to your parent object?

@stof
Copy link

stof commented Mar 6, 2013

If you don't have a way to access the parent object from this object, there is no way to build a property path for it (or to retrieve the value when the tool has your object)

@baldurrensch
Copy link
Contributor Author

No, I think I wasn't clear in my previous comment. Let me give you an example:

/**
 * @Relations(
 *     @Relation("author", href = @Route("author", 
 *       "parameters" = { "bookId" = "id", "authorId" = "id" })),
 *       "property" = "author"
 * )
 */
class Book
{
    private $id;
    private $authors; // That's the collection
}

How do you now distinguish between taking the id of Book, versus the id of Author?

@adrienbrault
Copy link
Contributor

You traverse the graph back:

/**
 * @Relations(
 *     @Relation("author", href = @Route("author", 
 *       "parameters" = { "bookId" = "book.id", "authorId" = "id" })),
 *       "property" = "author"
 * )
 */
class Book
{
    private $id;
    private $authors; // That's the collection
}

@baldurrensch
Copy link
Contributor Author

If that actually exists, or, something like this:

/**
 * @Relations(
 *     @Relation("author", href = @Route("author", 
 *       "parameters" = { "bookId" = "id" })),
 *       "property" = { "author" = { "authorId" = "id" } }
 * )
 */
class Book
{
    private $id;
    private $authors; // That's the collection
}

@cblegare
Copy link

One year later, ping ?

@adrienbrault
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants