Skip to content

Instantly share code, notes, and snippets.

@whitewhidow
Created March 5, 2015 14:53
Show Gist options
  • Save whitewhidow/20439aa17b9fdd90c920 to your computer and use it in GitHub Desktop.
Save whitewhidow/20439aa17b9fdd90c920 to your computer and use it in GitHub Desktop.
get entity from unitofwork, after persist, before flush
public function getFromBuffer($searchedValue, $method, $className = null){
$neededObject = array_filter(
$this->doctrine->getManager()->getUnitOfWork()->getScheduledEntityInsertions(),
function ($e) use (&$searchedValue, $method, $className) {
if (method_exists($e, $method) and ((get_class($e) == $className) or is_null($className))) {
return $e->$method() == $searchedValue;
} else {
}
return null;
}
);
return $neededObject;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment