private function createMedia(Media $media)
    {
        $request = $this->getRequest();
        $thumbSizes = $this->container->getParameter('fulgurio_light_cms.thumbs');
        $form = $this->createForm(new AdminMediaType($this->container), $media);
        $formHandler = new AdminMediaHandler();
        $formHandler->setForm($form)
                ->setRequest($request)
                ->setDoctrine($this->getDoctrine())
                ->setUser($this->getUser())
                ->setMediaLibraryService($this->get('fulgurio_light_cms.media_library'));
        if ($formHandler->process($media))
        {
            if ($request->isXmlHttpRequest())
            {
                return $this->jsonResponse((object) array('files' => array(
                    (object) array(
                        'id' => $media->getId(),
                        'name' => $media->getOriginalName(),
                        'url' => $media->getFullPath(),
                        'thumbnail_url' => LightCMSUtils::getThumbFilename($media->getFullPath(), $media->getMediaType(), $thumbSizes['medium']),
                        'delete_url' => $this->generateUrl('AdminMediasRemove', array('mediaId' => $media->getId(), 'confirm' => 'yes')),
                        'delete_type' => 'GET'
                    )
                )));
            }
            $this->get('session')->getFlashBag()->add(
                'success',
                $this->get('translator')->trans(
                    isset($options['pageId']) ? 'fulgurio.lightcms.medias.edit_form.success_msg' : 'fulgurio.lightcms.medias.add_form.success_msg',
                    array(),
                    'admin'
                )
            );
            return $this->redirect($this->generateUrl('AdminMedias'));
        }
        else if ($request->isXmlHttpRequest())
        {
            //@todo : well, we only manage one error, not the others ...
            return $this->jsonResponse((object) array('files' => array(
                    (object) array(
                            'error' => $this->get('translator')->trans('fulgurio.lightcms.medias.add_form.error_msg', array('%MAX_FILE_SIZE%' => ini_get('upload_max_filesize')), 'admin'),
                    )
            )));
        }
        $options['form'] = $form->createView();
        return $this->render('FulgurioLightCMSBundle:AdminMedia:add.html.twig', $options);
    }