protected function provideTemplatingSystem(Application $app)
    {
        $templateDir = __DIR__ . '/../../../data/templates';

        // when installed using composer the templates are in a different folder
        $composerTemplatePath = __DIR__ . '/../../../../templates';
        if (file_exists($composerTemplatePath)) {
            $templateDir = $composerTemplatePath;
        }

        // parameters
        $app['transformer.template.location'] = $templateDir;

        // services
        $app['transformer.template.path_resolver'] = $app->share(
            function ($container) {
                return new PathResolver($container['transformer.template.location']);
            }
        );

        $app['transformer.template.factory'] = $app->share(
            function ($container) {
                return new Factory(
                    $container['transformer.template.path_resolver'],
                    $container['serializer']
                );
            }
        );

        $app['transformer.template.collection'] = $app->share(
            function ($container) {
                return new Template\Collection(
                    $container['transformer.template.factory'],
                    $container['transformer.writer.collection']
                );
            }
        );
    }