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 generate link for itself #117

Merged
merged 7 commits into from
Jan 21, 2014
Merged

Allow generate link for itself #117

merged 7 commits into from
Jan 21, 2014

Conversation

bakura10
Copy link
Member

This is a first try to generate links for a resource. It's not tested yet, but should work for one resource. However I have no idea about how this could work for associations or any other links... :(

@bakura10
Copy link
Member Author

Maybe it could work with a syntax like:

$this->url->fromRoute(null, ['resource' => $user, 'association' => 'tweets']);

It would output "/users/4/tweets" for instance.

@bakura10
Copy link
Member Author

Done. But this is obviously quite limited and cannot handle more than one level of recursion.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.88%) when pulling dcc8c30 on router-assemble into b4aecf8 on master.

@coveralls
Copy link

Coverage Status

Coverage decreased (-1.88%) when pulling bdf3f97 on router-assemble into b4aecf8 on master.

$classMetadata = $resourceMetadata->getClassMetadata();
$identifiers = $classMetadata->getIdentifierValues($resource->getData());

$route = '/' . rtrim($this->route, '/') . '/' . current($identifiers);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need to throw an exception on multi-key identifiers

@coveralls
Copy link

Coverage Status

Coverage remained the same when pulling 2772222 on router-assemble into b4aecf8 on master.

@bakura10
Copy link
Member Author

Thanks!

bakura10 added a commit that referenced this pull request Jan 21, 2014
Allow generate link for itself
@bakura10 bakura10 merged commit 31da0f0 into master Jan 21, 2014
@bakura10 bakura10 deleted the router-assemble branch January 21, 2014 14:54
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

Successfully merging this pull request may close these issues.

None yet

3 participants