Skip to content

Instantly share code, notes, and snippets.

@guiwoda
Created February 13, 2015 13:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guiwoda/da0ab1c8df2bae2b8c7f to your computer and use it in GitHub Desktop.
Save guiwoda/da0ab1c8df2bae2b8c7f to your computer and use it in GitHub Desktop.
Delegate creation responsibility to EM / Repos
<?php
class FooRepository extends EntityRepository implements FooRepositoryInterface
{
public function startFooing($bar, $baz)
{
$em = $this->getEntityManager();
// Let's imagine we could
$foo = $em->create(Foo::class, [$bar, $baz]);
// And EM could resolve other dependencies (like the Emitter)
return $foo;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment