doctrine / doctrine/phpcr-odm

Selecting nodes based on association doesn't work

Open
#682 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
PHP
Stars
181
Forks
102
PR merge metrics
No merged PRs in 30d

Description

According to [the documentation](http://docs.doctrine-project.org/projects/doctrine-phpcr-odm/en/latest/reference/working-with-objects.html#by-simple-conditions) this code should work to select a node based on an association:

``` php
$number = $dm->find('MyProject\Domain\Phonenumber', '/path/to/phone/number');
$user = $dm->getRepository('MyProject\Domain\User')->findOneBy(array('phone' => $number->getUuid()));
```

However, when using this code to get a `MenuNode` documentation with a specific content object, I get an error:
_The code_

``` php
$dm = $this->get('doctrine_phpcr')->getManager();
$contentUuid = $dm->getPhpcrSession()->getItem('/cms/content/home')->getPropertyValue('jcr:uuid');

$dm->getRepository(MenuNode::class)->findOneBy(['content' => $contentUuid]);
```

_The error_

> Cannot use association property "content" of class "...\MenuNode" as a dynamic operand

The docs seem to be incorrect.

More importantly, I can't find a way to select the node. The QueryBuilder can't help with this either.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.