I have two pages in my content tree n sulu 1.0.13. On page "A" I set a reference to page "B" with a field of the content type "single internal link".
When I am on page "B" I want to get the referring page "A". I have tried following code in my controller:
$dm = $this->get('sulu_document_manager.document_manager');
$doc = $dm->find('992758cf-1da4-4e45-9ee4-ca9c4ec3998e'); // UUID of page "B"
$di = $this->get('sulu_document_manager.document_inspector');
$node = $di->getNode($doc);
$refs = $di->getReferrers($doc); // $refs is an empty collection
$refs = $node->getReferences(); // $refs is an empty collection
$refs = $node->getWeakReferences(); // $refs is an empty collection
$refs is always an empty collection.
What is the right way to get the referring page?
Update: I now use version 1.1.0 RC2
Sadly the SingleInternalLink
content type is currently just saving the UUID as a string, and not as a proper reference in PHPCR. This is also described in this GitHub Issue. I will reevaluate this issue, and see if we can fix that in the near future.
As a workaround you could use the InternalLinks
content type, which already saves its values as references, although it is possible to add more than one link.