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

[DoctrineWriter] Get entity after writeItem() method call #271

Open
fsevestre opened this issue Oct 1, 2015 · 0 comments
Open

[DoctrineWriter] Get entity after writeItem() method call #271

fsevestre opened this issue Oct 1, 2015 · 0 comments

Comments

@fsevestre
Copy link

Hi guys,

I would like to be able to retrieve the entity persisted after calling writeItem on the DoctrineWriter.

Here is my use case:

$foos = array( // Will be a `FooEntity`
    'name' => 'foo',
    'bars' => array( // Will be a collection of `BarEntity` with a `foo` (`FooEntity`) property
        array(
            'title' => 'bar',
        ),
        array(
            'title' => 'bar2',
        )
    )
)


$fooWriter = new DoctrineWriter($entityManager, 'AppBundle:FooEntity');
$fooWriter->prepare();

$barWriter = new DoctrineWriter($entityManager, 'AppBundle:BarEntity');
$barWriter->prepare();

foreach ($foos as $foo) {
    $fooWriter->writeItem(
        array(
            'name' => $foo['name'],
        )
    )

    foreach ($foo['bars'] as $bar) {
        $barWriter->writeItem(
            array(
                 'foo' => ???? not possible ATM,
                 'title' => $bar['title'],
             )
    }
}

...

I'll open a PR.

Cheers

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