我有一个补丁代码,要求编辑条形码1。目前,它不检查条形码是否存在于我们的数据库中。我希望能够检查数据库中是否存在条形码。在Symfony学说中,最好的方法是什么?
//*this is new logic that is a work in progress
if($eventAttendee->setBarcode1())
*//
$this->getApi()->setData($eventAttendee);
if ($this->getApi()->isValid() )
{
// Persist changes to the database
$this->get('doctrine')->getManager()->flush();
}
else
{
// Return a 400, bad request
return $this->view(
$this->getApi()->serialize(
$this->getApi()->getApiRequestErrors()
),
400
);
}
return $this->getApi()->serialize($eventAttendee);
}
catch (\Exception $e)
{
$this->get('logger')->error($e->getMessage());
}