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

entityLinks from Collection are not set in the embeded entity. #1

Open
weierophinney opened this issue Dec 31, 2019 · 1 comment
Open

Comments

@weierophinney
Copy link
Contributor

If I set entity links within collection using $collection->setEntityLinks($LinkColection) these are not rendered.
Within Hal plugin exctractCollection() method if the $entity has metadataMap then its created from metadataMap inclusive links.

if (is_object($entity) && $metadataMap->has($entity)) { $entity = $this->getResourceFactory()->createEntityFromMetadata($entity, $metadataMap->get($entity)); }

After that there is only the call for rendering the $entity.
if ($entity instanceof Entity) { // Depth does not increment at this level $collection[] = $this->renderEntity($entity, $this->getRenderCollections(), $depth, $maxDepth); continue; }

Probably there shall be a call to $entity->setLink($halCollection->getEntityLinks()) before the rendering.


Originally posted by @vlx73 at zfcampus/zf-hal#175

@weierophinney
Copy link
Contributor Author

I would propose following change . in the protected method of class Hal

`protected function extractCollection(Collection $halCollection, $depth = 0, $maxDepth = null)
{
...
if ($entity instanceof Entity) {

            // inject entity links from the parrent Collection
            if (!is_null($halCollection->getEntityLinks())) {
                $entityLinks = $entity->getLinks();
                foreach ($halCollection->getEntityLinks() as $collectionsEntityLink)
                    $entityLinks->idempotentAdd($collectionsEntityLink);
            }

            // Depth does not increment at this level
            $collection[] = $this->renderEntity($entity, $this->getRenderCollections(), $depth, $maxDepth);
            continue;
        }`

Originally posted by @vlx73 at zfcampus/zf-hal#175 (comment)

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

1 participant