Skip to content

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

Open

Description

@fsevestre

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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions