public function createMapping(Application $app)
    {
        $mapping = new Pimple;

        foreach ($app['ems.options'] as $name => $options) {
            $mapping[$name] = $mapping->share(
                function () use ($app, $options) {
                    $class = 'Doctrine\ORM\Mapping\Driver\\'
                           . $options['mapping_driver'];

                    switch ($options['mapping_driver'])
                    {
                        case 'AnnotationDriver':
                            $config = new Configuration;

                            return $config->newDefaultAnnotationDriver(
                                $options['mapping_paths']
                            );
                        case 'XmlDriver':
                            return new $class (
                                $options['mapping_paths']
                            );
                        case 'YamlDriver':
                            $driver = new $class (
                                $options['mapping_paths'],
                                '.yml'
                            );

                            return $driver;
                        default:
                            throw new InvalidArgumentException (
                                "Unsupported mapping class: $class"
                            );
                    }
                }
            );
        }

        return $mapping;
    }