function editMedia($slug, Request $request, Application $app)
 {
     if (!$this->build($slug, $request, $app)) {
         $app->abort(404, "Venue does not exist.");
     }
     if ($app['currentUserPermissions']->hasPermission("org.openacalendar", "CALENDAR_CHANGE") && $app['currentSite']->getIsFeaturePhysicalEvents()) {
         $form = $app['form.factory']->create(new UploadNewMediaForm($this->parameters['venue']->getTitle()));
         if ('POST' == $request->getMethod()) {
             $form->bind($request);
             if ($form->isValid() && $form['media']->getData()) {
                 $mediaRepository = new MediaRepository();
                 $media = $mediaRepository->createFromFile($form['media']->getData(), $app['currentSite'], $app['currentUser'], $form['title']->getData(), $form['source_text']->getData(), $form['source_url']->getData());
                 if ($media) {
                     $mediaInVenueRepo = new MediaInVenueRepository();
                     $mediaInVenueRepo->add($media, $this->parameters['venue'], $app['currentUser']);
                     $app['flashmessages']->addMessage('Picture added!');
                     return $app->redirect("/venue/" . $this->parameters['venue']->getSlugForURL());
                 }
             }
         }
         $this->parameters['uploadNewMediaForm'] = $form->createView();
     }
     $mrb = new MediaRepositoryBuilder();
     $mrb->setIncludeDeleted(false);
     $mrb->setSite($app['currentSite']);
     $mrb->setVenue($this->parameters['venue']);
     $this->parameters['medias'] = $mrb->fetchAll();
     return $app['twig']->render('site/venue/edit.media.html.twig', $this->parameters);
 }
 function profile(Request $request, Application $app)
 {
     $form = $app['form.factory']->create(new SiteEditProfileForm($app['config']), $app['currentSite']);
     if ('POST' == $request->getMethod()) {
         $form->bind($request);
         if ($form->isValid()) {
             $siteRepository = new SiteRepository();
             $siteRepository->edit($app['currentSite'], $app['currentUser']);
             if ($app['config']->isFileStore()) {
                 $newLogo = $form['logo']->getData();
                 if ($newLogo) {
                     $mediaRepository = new MediaRepository();
                     $media = $mediaRepository->createFromFile($newLogo, $app['currentSite'], $app['currentUser']);
                     if ($media) {
                         $app['currentSite']->setLogoMediaId($media->getId());
                         $siteProfileMediaRepository = new SiteProfileMediaRepository();
                         $siteProfileMediaRepository->createOrEdit($app['currentSite'], $app['currentUser']);
                     }
                 }
             }
             $app['flashmessages']->addMessage("Details saved.");
             return $app->redirect("/admin/");
         }
     }
     return $app['twig']->render('site/admin/profile.html.twig', array('form' => $form->createView()));
 }