public function GatsbyInstantPreview::gatsbyPrepareDelete in Gatsby Live Preview & Incremental Builds 8
Same name and namespace in other branches
- 2.0.x modules/gatsby_instantpreview/src/GatsbyInstantPreview.php \Drupal\gatsby_instantpreview\GatsbyInstantPreview::gatsbyPrepareDelete()
Triggers the refreshing of Gatsby preview and incremental builds.
Overrides GatsbyPreview::gatsbyPrepareDelete
File
- modules/
gatsby_instantpreview/ src/ GatsbyInstantPreview.php, line 123
Class
- GatsbyInstantPreview
- Defines a class to extend the default preview system with an instant preview.
Namespace
Drupal\gatsby_instantpreviewCode
public function gatsbyPrepareDelete(ContentEntityInterface $entity = NULL) {
$json = [
'id' => $entity
->uuid(),
'action' => 'delete',
'type' => $entity
->getEntityType()
->id() . '--' . $entity
->bundle(),
'attributes' => [
'langcode' => $entity
->language()
->getId(),
'drupal_internal__revision_id' => $entity
->getRevisionId(),
],
];
$settings = $this->configFactory
->get('gatsby.settings');
// The id and action are needed in a data array for batch processing.
$json['data'] = $json;
// If there is a secret key, add the key to the request.
if ($settings
->get('secret_key')) {
$json['secret'] = $settings
->get('secret_key');
}
$preview_url = $settings
->get('preview_callback_url');
if ($preview_url) {
$preview_json = $this
->bundleData('preview', $preview_url, $json);
$this
->updateData('preview', $preview_url, $preview_json);
}
$incrementalbuild_url = $settings
->get('incrementalbuild_url');
if ($incrementalbuild_url) {
$json = $this
->bundleData('incrementalbuild', $incrementalbuild_url, $json);
$this
->updateData('incrementalbuild', $incrementalbuild_url, $json);
}
}