请我需要你的帮助,我正在尝试使用 nelmio 包插入图像,但它给了我这个错误参数标签值''违反了约束(类型为 \"array 或 Traversable\",\"string\" 的预期参数)"
我的控制器如下
/**
* @ApiDoc(description="Uploads photo with tags.")
*
* @Rest\FileParam(name="image", image=true, description="Image to upload.")
* @Rest\RequestParam(name="tags", requirements=".+", nullable=false, map=true, description="Tags that associates photo.")
* @Rest\View()
*/
public function postPhotoAction(ParamFetcher $paramFetcher, array $tags)
{
$em = $this->getDoctrine()->getManager();
$photo = new Photo();
$form = $this->createForm(new PhotoType, $photo);
if ($tags) {
$tags = $em->getRepository('TestTaskTagsBundle:Tag')->findOrCreateByTitles($tags);
}
$form->submit($paramFetcher->all());
if (!$form->isValid()) {
return $form->getErrors();
}
foreach ($tags as $tag) {
$photo->addTag($tag);
}
$em->persist($photo);
$em->flush();
return array('photo' => $photo);
}
请问如何解决