function acquia_contenthub_unsubscribe_sync_state_submit in Acquia Content Hub 8.2
Submit handler for dealing with contenthub auto updating status.
Parameters
array $form: The form array.
\Drupal\Core\Form\FormStateInterface $form_state: The current form state.
Throws
\Exception
File
- modules/
acquia_contenthub_unsubscribe/ acquia_contenthub_unsubscribe.module, line 65 - Drupal Module: Acquia Content Hub unsubscribe.
Code
function acquia_contenthub_unsubscribe_sync_state_submit(array &$form, FormStateInterface $form_state) {
if (!$form_state
->hasValue('acquia_contenthub_subscriber_sync')) {
return;
}
/** @var \Drupal\Core\Entity\EntityFormInterface $object */
$object = $form_state
->getFormObject();
$entity = $object
->getEntity();
if (!$entity) {
return;
}
/** @var \Drupal\acquia_contenthub_subscriber\SubscriberTracker $tracker */
$tracker = \Drupal::service('acquia_contenthub_subscriber.tracker');
if ($form_state
->getValue('acquia_contenthub_subscriber_sync')) {
$tracker
->setStatusByTypeId($entity
->getEntityTypeId(), $entity
->id(), SubscriberTracker::AUTO_UPDATE_DISABLED);
}
else {
$tracker
->setStatusByTypeId($entity
->getEntityTypeId(), $entity
->id(), SubscriberTracker::QUEUED);
// @todo re-enqueue the entity to be updated to the current version in the services.
}
}