protected function throwsExceptionIfEntityNotFound($entityName, $id)
    {
        if (null === $entity = $this->getRepository($entityName)->find($id)) {
            throw new \InvalidArgumentException(sprintf('Cannot find `%s` with id `%s`.', $entityName, $id));
        }

        return $entity;
    }
protected function throwsExceptionIfEntityNotFound($entityName, $id)
    {
        if (null === $entity = $this->getRepository($entityName)->find($id)) {
            throw new \InvalidArgumentException(sprintf('Cannot find `%s` with id `%s`.', $entityName, $id));
        }

        return $entity;
    }
protected function throwsExceptionIfEntityNotFound ( $ entityName , $ id ) { if ( null === $ entity = $ this -> getRepository ( $ entityName ) -> find ( $ id ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot find `%s` with id `%s`.' , $ entityName , $ id ) ) ; } return $ entity ; }
Tries to get entity with provided identifier and throws exception if not found.

Note that you should not provide namespace prefix (=BackBee\Bundle\AdminBundle\Entity).

@param  string $entityName The entity namespace
@param  string $id         The identifier to find
@return object
@throws \InvalidArgumentException if cannot find entity with provided identifier
Tries to get entity with provided identifier and throws exception if not found .