public static function onFlushElementFile(Event $event)
    {
        $revision = $event->getTarget();
        $content = $revision->getContent();

        if (!($content instanceof ElementFile) || !is_file($content->path)) {
            return;
        }

        $application = $event->getApplication();
        $em = $application->getEntityManager();
        $uow = $em->getUnitOfWork();

        if ($uow->isScheduledForDelete($content)) {
            return;
        }

        $fileRepository = $em->getRepository('BackBee\ClassContent\Element\File');
        $fileRepository->setDirectories($application);

        $fileRepository->commitFile($content);

        $moveFrom = $content->path;
        File::resolveFilepath($moveFrom, null, array('base_dir' => $application->getMediaDir()));

        if (file_exists($moveFrom)) {
            $content->setParam('stat', json_encode(stat($moveFrom)));

            if ($content instanceof ElementImage) {
                list($width, $height) = getimagesize($moveFrom);

                $content->setParam('width', $width);
                $content->setParam('height', $height);
            }
        }

        $uow->recomputeSingleEntityChangeSet($em->getClassMetadata('BackBee\ClassContent\Revision'), $revision);
    }