acquia_lift_publisher.module in Acquia Lift Connector 8.4
Drupal Module: Acquia Lift - Publisher.
Acquia Content Hub Publisher exports content from your Drupal site to Content Hub services. This module alters the behavior of the default functionality.
File
modules/acquia_lift_publisher/acquia_lift_publisher.moduleView source
<?php
/**
* @file
* Drupal Module: Acquia Lift - Publisher.
*
* Acquia Content Hub Publisher exports content from your Drupal site to
* Content Hub services. This module alters the behavior of the default
* functionality.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\acquia_lift_publisher\Form\ContentPublishingForm;
/**
* Implements hook_entity_insert().
*/
function acquia_lift_publisher_entity_insert(EntityInterface $entity) {
$publishing_actions = Drupal::service('acquia_lift_publisher.publishing_actions');
$push_setting_field_value = $publishing_actions
->getPublicationsFieldValue(ContentPublishingForm::$pushSettingField, TRUE);
$export_content_immediately_field_value = $publishing_actions
->getPublicationsFieldValue(ContentPublishingForm::$exportContentImmediatelyField, TRUE);
if ($push_setting_field_value === TRUE && $export_content_immediately_field_value === TRUE) {
_acquia_lift_publisher_trigger_queue($entity);
}
}
/**
* Implements hook_entity_update().
*/
function acquia_lift_publisher_entity_update(EntityInterface $entity) {
$publishing_actions = Drupal::service('acquia_lift_publisher.publishing_actions');
$push_setting_field_value = $publishing_actions
->getPublicationsFieldValue(ContentPublishingForm::$pushSettingField, TRUE);
$export_content_immediately_field_value = $publishing_actions
->getPublicationsFieldValue(ContentPublishingForm::$exportContentImmediatelyField, TRUE);
if ($push_setting_field_value === TRUE && $export_content_immediately_field_value === TRUE) {
_acquia_lift_publisher_trigger_queue($entity);
}
}
/**
* Triggers the Content Hub export process.
*
* @param \Drupal\Core\Entity\EntityInterface $entity
* The current entity.
*/
function _acquia_lift_publisher_trigger_queue(EntityInterface $entity) : void {
\Drupal::getContainer()
->get('acquia_lift_publisher.publishing_actions')
->triggerQueue($entity);
}
/**
* Implements hook_module_implements_alter().
*/
function acquia_lift_publisher_module_implements_alter(&$implementations, $hook) {
// Make sure that acquia_contenthub_publisher module hooks run before
// acquia_lift_publisher hooks.
$hooks = [
'entity_insert',
'entity_update',
];
if (!in_array($hook, $hooks, TRUE)) {
return;
}
$module = 'acquia_lift_publisher';
$group = $implementations[$module];
unset($implementations[$module]);
$implementations[$module] = $group;
}
Functions
Name | Description |
---|---|
acquia_lift_publisher_entity_insert | Implements hook_entity_insert(). |
acquia_lift_publisher_entity_update | Implements hook_entity_update(). |
acquia_lift_publisher_module_implements_alter | Implements hook_module_implements_alter(). |
_acquia_lift_publisher_trigger_queue | Triggers the Content Hub export process. |