You are here

function bynder_cron in Bynder 8.3

Same name and namespace in other branches
  1. 8 bynder.module \bynder_cron()
  2. 8.2 bynder.module \bynder_cron()
  3. 7 bynder.module \bynder_cron()
  4. 4.0.x bynder.module \bynder_cron()

Implements hook_cron().

File

./bynder.module, line 208
Provides bynder integration.

Code

function bynder_cron() {
  $last_update = \Drupal::state()
    ->get('bynder_cache_last_update', 0);
  if ($last_update && $last_update + \Drupal::config('default')
    ->get('cache_lifetime') < \Drupal::time()
    ->getRequestTime()) {
    try {
      \Drupal::service('bynder_api')
        ->updateCachedData();
    } catch (\Exception $exception) {
      \Drupal::logger('bynder')
        ->error(t('Unable to update Bynder caches. Check your <a href=":url">connection configuration</a>.', [
        ':url' => Url::fromRoute('bynder.configuration_form')
          ->toString(),
      ]));
    }
  }

  // Update the metadata information of the local Bynder media entities.
  \Drupal::service('bynder')
    ->updateLocalMetadataCron();
}