Doctrine\ODM\MongoDB\DocumentManager::find PHP Method

find() public method

This is just a convenient shortcut for getRepository($documentName)->find($id).
public find ( string $documentName, mixed $identifier, integer $lockMode = LockMode::NONE, integer $lockVersion = null ) : object
$documentName string
$identifier mixed
$lockMode integer
$lockVersion integer
return object $document
    public function find($documentName, $identifier, $lockMode = LockMode::NONE, $lockVersion = null)
    {
        return $this->getRepository($documentName)->find($identifier, $lockMode, $lockVersion);
    }

Usage Example

 /**
  * @param  string $id
  * @return Recipe
  * @throws NotFoundException If no Recipe found
  */
 public function find($id)
 {
     $recipe = $this->dm->find('Hellofresh\\DoctrineTutorial\\Menu\\Recipe', $id);
     if (!$recipe) {
         throw new NotFoundException("Recipe not found");
     }
     return $recipe;
 }
All Usage Examples Of Doctrine\ODM\MongoDB\DocumentManager::find