aggregator.install 1.88 KB
Newer Older
1 2
<?php

3 4 5 6 7
/**
 * @file
 * Install, update and uninstall functions for the aggregator module.
 */

8 9 10 11 12
/**
 * Implements hook_requirements().
 */
function aggregator_requirements($phase) {
  $has_curl = function_exists('curl_init');
13 14
  $requirements = [];
  $requirements['curl'] = [
15 16
    'title' => t('cURL'),
    'value' => $has_curl ? t('Enabled') : t('Not found'),
17
  ];
18 19
  if (!$has_curl) {
    $requirements['curl']['severity'] = REQUIREMENT_ERROR;
20
    $requirements['curl']['description'] = t('The Aggregator module requires the <a href="https://secure.php.net/manual/en/curl.setup.php">PHP cURL library</a>. For more information, see the <a href="https://www.drupal.org/requirements/php/curl">online information on installing the PHP cURL extension</a>.');
21 22 23
  }
  return $requirements;
}
24 25 26 27 28 29 30 31

/**
 * The simple presence of this update function clears cached field definitions.
 */
function aggregator_update_8001() {
  // Feed ID base field is now required.
}

32 33 34 35 36 37 38 39 40 41 42
/**
 * Make the 'Source feed' field for aggregator items required.
 */
function aggregator_update_8200() {
  // aggregator_update_8001() did not update the last installed field storage
  // definition for the aggregator item's 'Source feed' field.
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_definition = $definition_update_manager->getFieldStorageDefinition('fid', 'aggregator_item');
  $field_definition->setRequired(TRUE);
  $definition_update_manager->updateFieldStorageDefinition($field_definition);
}
43 44 45 46 47 48 49 50 51 52

/**
 * Add a default value for the 'Refresh' field for aggregator feed entities.
 */
function aggregator_update_8501() {
  $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  $field_definition = $definition_update_manager->getFieldStorageDefinition('refresh', 'aggregator_feed');
  $field_definition->setDefaultValue(3600);
  $definition_update_manager->updateFieldStorageDefinition($field_definition);
}