protected function build($siteid, $slug, Request $request, Application $app)
 {
     $this->parameters = array('user' => null, 'eventCreated' => null, 'eventDupe' => null);
     $sr = new SiteRepository();
     $this->parameters['site'] = $sr->loadById($siteid);
     if (!$this->parameters['site']) {
         $app->abort(404);
     }
     $repo = new NewEventDraftRepository();
     $this->parameters['draft'] = $repo->loadBySlugForSite($slug, $this->parameters['site']);
     if (!$this->parameters['draft']) {
         $app->abort(404);
     }
     if ($this->parameters['draft']->getUserAccountId()) {
         $ur = new UserAccountRepository();
         $this->parameters['user'] = $ur->loadByID($this->parameters['draft']->getUserAccountId());
     }
     if ($this->parameters['draft']->getEventId()) {
         $er = new EventRepository();
         $this->parameters['eventCreated'] = $er->loadByID($this->parameters['draft']->getEventId());
     }
     if ($this->parameters['draft']->getWasExistingEventId()) {
         $er = new EventRepository();
         $this->parameters['eventDupe'] = $er->loadByID($this->parameters['draft']->getWasExistingEventId());
     }
 }
 function newEventIsDupeOf($draftslug, $eventslug, Request $request, Application $app)
 {
     if (!$this->buildDraft($draftslug, $request, $app)) {
         return $app->abort(404);
     }
     $er = new EventRepository();
     $event = $er->loadBySlug($app['currentSite'], $eventslug);
     if (!$event) {
         return $app->abort(404);
     }
     $ner = new NewEventDraftRepository();
     $ner->markIsDuplicateOf($this->parameters['draft'], $event);
     return $app->redirect('/event/' . $event->getSlugForUrl());
 }