This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| val doc = response.results.head | |
| val resolver = DocumentLinkResolver { link => | |
| s"/testing_url/${link.id}/${link.slug}" | |
| } | |
| val html = doc.getStructuredText("blog-post.body").map(_.asHtml(resolver)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Api api = Api.get("https://lesbonneschoses.prismic.io/api"); | |
| for (Ref ref: api.getRefs()) { | |
| System.out.println("Reference: " + ref); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Api api = Api.get("https://lesbonneschoses.prismic.io/api"); | |
| // The response object contains all documents of type "product", paginated | |
| Response response = api.getForm("everything") | |
| .ref(api.getMaster()) | |
| .query(Predicates.at("document.type", "product")) | |
| .submit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Api api = Api.get("https://lesbonneschoses.prismic.io/api"); | |
| // The response object contains all documents of type "product", paginated | |
| Response response = api.getForm("everything") | |
| .ref(api.getMaster()) | |
| .query( | |
| Predicates.at("document.type", "product"), | |
| Predicates.dateAfter("my.blog-post.date", new DateTime(2014, 6, 1, 0, 0)) | |
| ).submit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Document doc = response.getResults().get(0); | |
| DocumentLinkResolver resolver = new DocumentLinkResolver() { | |
| @Override public String resolve(Fragment.DocumentLink link) { | |
| return "/"+link.getId()+"/"+link.getSlug(); | |
| } | |
| }; | |
| String html = doc.getStructuredText("blog-post.body").asHtml(resolver); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Document doc = response.getResults().get(0); | |
| final DocumentLinkResolver resolver = new DocumentLinkResolver() { | |
| @Override public String resolve(Fragment.DocumentLink link) { | |
| return "/"+link.getId()+"/"+link.getSlug(); | |
| } | |
| }; | |
| HtmlSerializer serializer = new HtmlSerializer() { | |
| @Override public String serialize(Fragment.StructuredText.Element element, String content) { | |
| if (element instanceof Fragment.StructuredText.Block.Image) { | |
| // Don't wrap images in <p> tags |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $api = Api::get("https://lesbonneschoses.prismic.io/api"); | |
| $masterRef = $api->master(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $api = Api::get("https://lesbonneschoses.prismic.io/api"); | |
| $response = $api | |
| ->forms()->everything | |
| ->query(Predicates::at("document.type", "product")) | |
| ->ref($api->master()) | |
| ->submit(); | |
| // $response contains all documents of type "product", paginated |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $api = Api::get("https://lesbonneschoses.prismic.io/api"); | |
| $response = $api | |
| ->forms() | |
| ->everything | |
| ->query(array( | |
| Predicates::at("document.type", "product"), | |
| Predicates::at("my.blog-post.date", 1401580800000))) | |
| ->ref($api->master()->getRef()) | |
| ->submit(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $results = $response->getResults(); | |
| $doc = $results[0]; | |
| // The resolver is defined here: | |
| // https://github.com/prismicio/php-kit/blob/master/tests/Prismic/FakeLinkResolver.php | |
| $resolver = new FakeLinkResolver(); | |
| $html = $doc->getStructuredText("blog-post.body")->asHtml($resolver); |