use of com.enonic.xp.page.PageTemplates in project xp by enonic.
the class GetPageTemplateBySiteCommand method execute.
public PageTemplates execute() {
final PageTemplates.Builder pageTemplatesBuilder = PageTemplates.create();
if (sitePath == null) {
final Content site = contentService.getById(siteId);
sitePath = site.getPath();
}
final ContentPath pageTemplatesFolderPath = ContentPath.from(sitePath, ContentServiceImpl.TEMPLATES_FOLDER_NAME);
final FindContentByParentParams.Builder findContentByParentParams = FindContentByParentParams.create().parentPath(pageTemplatesFolderPath);
if (supportedContentTypes != null) {
final ValueFilter.Builder supportsContentTypeFilter = ValueFilter.create().fieldName("data.supports");
supportedContentTypes.forEach(supportedContentType -> {
supportsContentTypeFilter.addValue(ValueFactory.newString(supportedContentType.toString()));
});
findContentByParentParams.queryFilter(supportsContentTypeFilter.build());
}
if (size != null) {
findContentByParentParams.size(size);
}
final FindContentByParentResult result = contentService.findByParent(findContentByParentParams.build());
for (final Content content : result.getContents()) {
if (content instanceof PageTemplate) {
pageTemplatesBuilder.add((PageTemplate) content);
}
}
return pageTemplatesBuilder.build();
}
Aggregations