Skip to content

Instantly share code, notes, and snippets.

@emilong
Last active March 28, 2016 21:07
Show Gist options
  • Save emilong/7bfc0a507f5bdffa7048 to your computer and use it in GitHub Desktop.
Save emilong/7bfc0a507f5bdffa7048 to your computer and use it in GitHub Desktop.
// Factory
function createPdfGenerator(Content, PdfApi) {
return {
generate: function(contentId) {
const content = Content.find(contentId);
return PdfApi.render(content.format());
}
};
}
// Export a function that registers the service provider with the given container.
modules.export = function(bottle) {
bottle.service(
'service.PdfGenerator', // the name of the service we're providing
createPdfGenerator, // the factory to create the service instance
'model.Content', 'client.PdfApi' // the dependencies required to create the factory
);
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment