private function canDelete(Photo $photo, User $user = null) { if ($photo->getAuthor() == $user) { return true; } if ($photo->getAlbum()->getAuthors()->contains($user)) { return true; } return false; }