Skip to content

Instantly share code, notes, and snippets.

@dave1010
Created November 18, 2014 08:04
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 dave1010/cc852a7136cc6618fc4d to your computer and use it in GitHub Desktop.
Save dave1010/cc852a7136cc6618fc4d to your computer and use it in GitHub Desktop.
cqs repo with creation on fetch
class Repo
{
public function fetchByName($name)
{
$entity = $this->em->fetch(['name' => $name]);
if (!$entity) {
$entity = new NullEntity($name);
}
$this->dispatcher->dispatch(new EntityRetrievedEvent($entity));
return $entity;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment