protected function getProduct($id) { $product = $this->productManager->findOneBy(array('id' => $id)); if (null === $product) { throw new NotFoundHttpException(sprintf('Product (%d) not found', $id)); } return $product; }