function history($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Venue does not exist.");
     }
     $historyRepositoryBuilder = new HistoryRepositoryBuilder();
     $historyRepositoryBuilder->setVenue($this->parameters['venue']);
     $this->parameters['historyItems'] = $historyRepositoryBuilder->fetchAll();
     return $app['twig']->render('site/venue/history.html.twig', $this->parameters);
 }
 function testIntegration2()
 {
     $this->addCountriesToTestDB();
     \TimeSource::mock(2014, 1, 1, 12, 0, 0);
     $user = new UserAccountModel();
     $user->setEmail("*****@*****.**");
     $user->setUsername("test");
     $user->setPassword("password");
     $userRepo = new UserAccountRepository();
     $userRepo->create($user);
     $site = new SiteModel();
     $site->setTitle("Test");
     $site->setSlug("test");
     $siteRepo = new SiteRepository();
     $siteRepo->create($site, $user, array(), $this->getSiteQuotaUsedForTesting());
     $countryRepo = new CountryRepository();
     $gb = $countryRepo->loadByTwoCharCode('GB');
     ## Create venue
     \TimeSource::mock(2014, 1, 1, 13, 0, 0);
     $venue = new VenueModel();
     $venue->setTitle("test");
     $venue->setDescription("test test");
     $venue->setCountryId($gb->getId());
     $venueRepo = new VenueRepository();
     $venueRepo->create($venue, $site, $user);
     ## Edit venue
     \TimeSource::mock(2014, 1, 1, 14, 0, 0);
     $venue = $venueRepo->loadById($venue->getId());
     $venue->setDescription("testy");
     $venue->setLat(3.6);
     $venue->setLng(3.7);
     $venueRepo->edit($venue, $user);
     ## Delete venue
     \TimeSource::mock(2014, 1, 1, 15, 0, 0);
     $venueRepo->delete($venue, $user);
     ## Now save changed flags on these .....
     $venueHistoryRepo = new VenueHistoryRepository();
     $stat = $this->app['db']->prepare("SELECT * FROM venue_history");
     $stat->execute();
     while ($data = $stat->fetch()) {
         $venueHistory = new VenueHistoryModel();
         $venueHistory->setFromDataBaseRow($data);
         $venueHistoryRepo->ensureChangedFlagsAreSet($venueHistory);
     }
     ## Now load and check
     $historyRepo = new HistoryRepositoryBuilder();
     $historyRepo->setVenue($venue);
     $historyRepo->setIncludeEventHistory(false);
     $historyRepo->setIncludeGroupHistory(false);
     $historyRepo->setIncludeVenueHistory(true);
     $histories = $historyRepo->fetchAll();
     $this->assertEquals(3, count($histories));
     #the delete
     $this->assertEquals(FALSE, $histories[0]->getTitleChanged());
     $this->assertEquals(false, $histories[0]->getDescriptionChanged());
     $this->assertEquals(false, $histories[0]->getCountryIdChanged());
     $this->assertEquals(true, $histories[0]->getIsDeletedChanged());
     $this->assertEquals(false, $histories[0]->getLatChanged());
     $this->assertEquals(false, $histories[0]->getLngChanged());
     #the edit
     $this->assertEquals(FALSE, $histories[1]->getTitleChanged());
     $this->assertEquals(true, $histories[1]->getDescriptionChanged());
     $this->assertEquals(false, $histories[1]->getCountryIdChanged());
     $this->assertEquals(false, $histories[1]->getIsDeletedChanged());
     $this->assertEquals(true, $histories[1]->getLatChanged());
     $this->assertEquals(true, $histories[1]->getLngChanged());
     #the create
     $this->assertEquals(true, $histories[2]->getTitleChanged());
     $this->assertEquals(true, $histories[2]->getDescriptionChanged());
     $this->assertEquals(true, $histories[2]->getCountryIdChanged());
     $this->assertEquals(false, $histories[2]->getIsDeletedChanged());
     $this->assertEquals(false, $histories[2]->getLatChanged());
     $this->assertEquals(false, $histories[2]->getLngChanged());
 }