Skip to content

Instantly share code, notes, and snippets.

Created January 2, 2021 05:36
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
namespace Customize\ArgumentResolver;
use Eccube\Entity\Product;
use Eccube\Repository\ProductRepository;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpKernel\Controller\ArgumentValueResolverInterface;
use Symfony\Component\HttpKernel\ControllerMetadata\ArgumentMetadata;
class ProductValueResolver implements ArgumentValueResolverInterface
* @var ProductRepository
private $productRepository;
public function __construct(ProductRepository $productRepository)
$this->productRepository = $productRepository;
public function supports(Request $request, ArgumentMetadata $argument)
return Product::class === $argument->getType();
public function resolve(Request $request, ArgumentMetadata $argument)
$id = $request->attributes->get('id');
yield $this->productRepository->findWithSortedClassCategories($id);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment