moved Entry VO away from implementations

This commit is contained in:
Cássio Zen
2016-10-27 15:27:39 -02:00
parent 1566e247f3
commit a33aa13d0f
3 changed files with 34 additions and 21 deletions

View File

@ -85,7 +85,6 @@ class Backend {
));
}
// We have the file path. Fetch and parse the file.
getEntry(collection, slug) {
return this.implementation.getEntry(collection, slug, new Collection(collection).entryPath(slug))
.then(loadedEntry => this.entryWithFormat(collection, slug)(createEntry(
@ -112,14 +111,31 @@ class Backend {
}
unpublishedEntries(page, perPage) {
return this.implementation.unpublishedEntries(page, perPage).then(response => ({
pagination: response.pagination,
entries: response.entries.map(this.entryWithFormat('editorialWorkflow')),
}));
return this.implementation.unpublishedEntries(page, perPage)
.then(loadedEntries => (
loadedEntries.map((loadedEntry) => {
const entry = createEntry('draft', loadedEntry.slug, loadedEntry.file.path, { raw: loadedEntry.data })
entry.metaData = loadedEntry.metaData;
return entry;
})
))
.then((entries) => {
const filteredEntries = entries.filter(entry => entry !== null);
return {
pagination: 0,
entries: filteredEntries.map(this.entryWithFormat('editorialWorkflow')),
};
});
}
unpublishedEntry(collection, slug) {
return this.implementation.unpublishedEntry(collection, slug).then(this.entryWithFormat(collection));
return this.implementation.unpublishedEntry(collection, slug)
.then(loadedEntry => this.entryWithFormat(collection, slug)(createEntry(
collection.get('name'),
slug,
loadedEntry.file.path,
{ raw: loadedEntry.data }
)));
}
persistEntry(config, collection, entryDraft, MediaFiles, options) {