Просто включите прослушиватель param fetcher в config.yml вашего Symfony:
ользую FOSRestBundle для своего проекта. Я настроил этот маршрут для доступа к разным видам данных:
`` `
/**
* @Rest\Get("")
*
* @Rest\QueryParam(
* name="categoriesId",
* requirements="[0-9a-zA-Z\- \/_:.,\s]",
* default="",
* description="The categories ids."
* )
* @Rest\QueryParam(
* name="orderBy",
* requirements="[a-zA-Z0-9]",
* default="score",
* description="The keyword to search for."
* )
* @Rest\QueryParam(
* name="order",
* requirements="asc|desc",
* default="desc",
* description="Sort order (asc or desc)"
* )
* @Rest\QueryParam(
* name="limit",
* requirements="\d+",
* default="-1",
* description="Max number of celebrities returned."
* )
* @Rest\QueryParam(
* name="offset",
* requirements="\d+",
* default="0",
* description="The offset"
* )
*
* @Rest\View(serializerEnableMaxDepthChecks=true)
* @param ParamFetcherInterface $fetcher
* @param EntityManagerInterface $em
* @return array
*/
public function getAction(ParamFetcherInterface $fetcher, EntityManagerInterface $em) {
// Get categories
$categories_id = explode(',', $fetcher->get('categoriesId'));
$options = [
'addProfilePicture' => true,
'addCategories' => true,
];
// Configure limit and order
if($fetcher->get('limit') !== -1)
$options['limit'] = $fetcher->get('limit');
$options['offset'] = $fetcher->get('offset');
// Configure order
switch ($fetcher->get('orderBy')) {
case 'score':
$options['orderBy'] = 'score';
}
$rows = $em->getRepository(Celebrity::class)->findByCategories($categories_id, $options);
return $rows;
}
`` `
Но когда я вызываю свой узел с почтальоном, у меня появляется эта ошибка:
Контроллер и метод должны быть установлены через setController
И ошибка исходит от ParamFetcher, и строка
$categories_id = explode(',', $fetcher->get('categoriesId'));
Есть ли у вас какие-либо идеи о происхождении этого вопроса: /?