/**
  * @Route("/settings/background/set/{id}", name="admin_settings_background_set", requirements={"id" = "\d+"})
  * @Template()
  * @ParamConverter("Background", class="ConnectionAdminBundle:Background")
  */
 public function backgroundSetAction(Background $background)
 {
     $em = $this->getDoctrine()->getManager();
     $defaultBackground = $this->getDoctrine()->getRepository('ConnectionAdminBundle:Background')->findBy(array('isDefault' => 1));
     foreach ($defaultBackground as $elem) {
         $elem->setIsDefault(0);
         $em->persist($elem);
     }
     $em->flush();
     $background->setIsDefault(1);
     $em->persist($background);
     $em->flush();
     return $this->redirect($this->generateUrl('admin_settings_background'));
 }
 private function processAdminBackgroundImage($event)
 {
     $file = $event->getFile();
     $config = $event->getConfig();
     if (!$file instanceof File) {
         throw new \Exception('Not instance of File');
     }
     $fileDir = str_replace($this->container->get('kernel')->getRootDir() . '/../web', "", $config['storage']['directory']);
     $image = new Background();
     $image->setName($file->getFilename());
     $image->setPath($fileDir . "/" . $file->getFilename());
     $em = $this->container->get('doctrine')->getManager();
     $em->persist($image);
     $em->flush();
 }
 /**
  * {@inheritDoc}
  */
 public function removeFiles()
 {
     $this->__initializer__ && $this->__initializer__->__invoke($this, 'removeFiles', array());
     return parent::removeFiles();
 }