public function detail(Request $request, Application $app, $hash) { if (!isset($hash)) { throw new Exception("Parâmetros inválidos", 1); } $share = $app['orm.em']->getRepository('Orcamentos\\Model\\Share')->findOneBy(array('hash' => $hash)); if (!$share) { $app->abort(404, "Compartilhamento não existente"); } $shareId = $share->getId(); $view = new ViewModel(); $view->setShare($share); $app['orm.em']->persist($view); $app['orm.em']->flush(); $quote = $share->getQuote(); $resourceCollection = $quote->getResourceQuoteCollection(); $shareCollection = $quote->getShareCollection(); $shareNotesCollection = array(); foreach ($shareCollection as $sc) { $notes = $sc->getShareNotesCollection(); foreach ($notes as $note) { $shareNotesCollection[] = $note; } } usort($shareNotesCollection, $app['sortCreated']); $city = $quote->getProject()->getCompany()->getCity(); $createdSignature = $this->createdSignature($quote->getCreated(), $city); return $app['twig']->render('share/detail.twig', array('quote' => $quote, 'resourceCollection' => $resourceCollection, 'createdSignature' => $createdSignature, 'shareNotesCollection' => $shareNotesCollection, 'shareId' => $shareId)); }