Maybe there is a simpler way of doing this. But I want to display entries (URLs) that were already found when trying to input in to a database table along with the current table. So in the controller I am trying to pass two arrays. One that is of the whole table and another of the entries it found matched the entries in the table. So the user can see they already existed.
$repository = $this->getDoctrine()->getRepository('ObjectBundle:object');
foreach ($mylinks as &$value) {
$linkexist = $repository->findOneByUrl($value);
if (!$linkexist) {
$obj = new Object();
$obj->setUrl($value);
$obj->setLastupdate(new \DateTime('now'));
$em = $this->getDoctrine()->getManager();
$em->persist($obj);
$em->flush();
} else {
$notfound = new Object();
$notfound->setUrl($value);
}
}
$em = $this->getDoctrine()->getManager();
$listurls = $em->getRepository('ObjectBundle:Object')->findAll();
return $this->render('object/index.html.twig', array(
'objects' => $listurls,
));
I would like to include the $notfound into a separate array or parse it without changing the Object entity. Any ideas?
$notfoundshould really be$existingor at least$found.