public function AcquiadamConfig::performManualSync in Media: Acquia DAM 8
Submit handler for "Synchronize all media assets" button.
Parameters
array $form: A Drupal form render array.
\Drupal\Core\Form\FormStateInterface $form_state: The FormState object.
Return value
array|bool An array of Media IDs that were set for a batch job, or FALSE on no media items found.
File
- src/
Form/ AcquiadamConfig.php, line 223
Class
- AcquiadamConfig
- Class AcquiadamConfig.
Namespace
Drupal\media_acquiadam\FormCode
public function performManualSync(array &$form, FormStateInterface $form_state) {
$media_ids = $this
->getActiveMediaIds();
if (!$media_ids) {
// No assets to synchronize.
$this
->messenger()
->addWarning($this
->t('The synchronization is canceled because no Assets were found.'));
return FALSE;
}
$this->batchBuilder
->setTitle($this
->t('Synchronizing media assets.'))
->setInitMessage($this
->t('Starting synchronization...'))
->setProgressMessage($this
->t('@elapsed elapsed. Approximately @estimate left.'))
->setErrorMessage($this
->t('An error has occurred.'))
->setFinishCallback([
$this,
'finishBatchOperation',
])
->addOperation([
$this,
'processBatchItems',
], [
$media_ids,
]);
$this
->batchSet($this->batchBuilder
->toArray());
return $media_ids;
}