Files
Phraseanet/lib/Alchemy/Phrasea/Model/Converter/BasketConverter.php
Nicolas Le Goff 66fa05f4ee Fix CS
2014-07-17 15:17:04 +02:00

41 lines
915 B
PHP

<?php
/*
* This file is part of Phraseanet
*
* (c) 2005-2014 Alchemy
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace Alchemy\Phrasea\Model\Converter;
use Alchemy\Phrasea\Model\Entities\Basket;
use Alchemy\Phrasea\Model\Repositories\BasketRepository;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
class BasketConverter implements ConverterInterface
{
private $repository;
public function __construct(BasketRepository $repository)
{
$this->repository = $repository;
}
/**
* {@inheritdoc}
*
* @return Basket
*/
public function convert($id)
{
if (null === $basket = $this->repository->find((int) $id)) {
throw new NotFoundHttpException(sprintf('Basket %s not found.', $id));
}
return $basket;
}
}