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

Flipped key/value for SimplifiedXmlDriver example #2061

Merged
merged 1 commit into from
Oct 1, 2019

Conversation

olvlvl
Copy link
Contributor

@olvlvl olvlvl commented Sep 17, 2019

Q A
Type bug
BC Break no

Summary

Hi,

I believe the example for SimplifiedXmlDriver is wrong, the keys/values are flipped. SymfonyFileLocator uses the keys as paths, see that array_keys($prefixes)?

    public function addNamespacePrefixes(array $prefixes)
    {
        $this->prefixes = array_merge($this->prefixes, $prefixes);
        $this->paths    = array_merge($this->paths, array_keys($prefixes));
    }

I would expect namespace prefix to be a key as well, but it's not the case. For instance the following code is not working:

    prefixes:
      HelloFresh\MenuService\Domain\Menu: src/Infrastructure/Persistence/Resource/doctrine/document/Menu
      HelloFresh\MenuService\Domain\Preset: src/Infrastructure/Persistence/Resource/doctrine/document/Preset

But this one is:

    prefixes:
      src/Infrastructure/Persistence/Resource/doctrine/document/Menu: HelloFresh\MenuService\Domain\Menu
      src/Infrastructure/Persistence/Resource/doctrine/document/Preset: HelloFresh\MenuService\Domain\Preset

Hi,

I believe the example for `SimplifiedXmlDriver` is wrong, the keys/values are flipped. [SymfonyFileLocator](https://github.com/doctrine/persistence/blob/2ae45c1436572dbcb1036801793b8b726c6a9f53/lib/Doctrine/Common/Persistence/Mapping/Driver/SymfonyFileLocator.php#L84) uses the keys as paths, see that `array_keys($prefixes)`?

```php
    public function addNamespacePrefixes(array $prefixes)
    {
        $this->prefixes = array_merge($this->prefixes, $prefixes);
        $this->paths    = array_merge($this->paths, array_keys($prefixes));
    }
```

I would expect namespace prefix to be a key as well, but it's not the case. For instance the following code is not working:

```yaml
    prefixes:
      HelloFresh\MenuService\Domain\Menu: src/Infrastructure/Persistence/Resource/doctrine/document/Menu
      HelloFresh\MenuService\Domain\Preset: src/Infrastructure/Persistence/Resource/doctrine/document/Preset
```

But this one is:

```yaml
    prefixes:
      src/Infrastructure/Persistence/Resource/doctrine/document/Menu: HelloFresh\MenuService\Domain\Menu
      src/Infrastructure/Persistence/Resource/doctrine/document/Preset: HelloFresh\MenuService\Domain\Preset
```
@alcaeus alcaeus changed the base branch from 1.2.x to 1.3.x October 1, 2019 07:01
@alcaeus alcaeus self-assigned this Oct 1, 2019
@alcaeus alcaeus added this to the 1.3.2 milestone Oct 1, 2019
@alcaeus alcaeus merged commit 16627dd into doctrine:1.3.x Oct 1, 2019
@alcaeus
Copy link
Member

alcaeus commented Oct 1, 2019

Thanks @olvlvl!

@olvlvl olvlvl deleted the patch-1 branch October 1, 2019 21:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants