Last active
March 24, 2023 17:02
-
-
Save joanfabregat/58be0250706c891e1b66f3941708b217 to your computer and use it in GitHub Desktop.
Get Doctrine Entity missing relation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* @noinspection PhpRedundantCatchClauseInspection | |
* @noinspection PhpUnusedLocalVariableInspection | |
*/ | |
public function getUser(): ?User | |
{ | |
try { | |
$this->user?->getId(); | |
return $this->user; | |
} | |
catch (EntityNotFoundException $e) { | |
return null; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment