aggregator.install 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. <?php
  2. /**
  3. * @file
  4. * Install, update and uninstall functions for the aggregator module.
  5. */
  6. /**
  7. * Implements hook_requirements().
  8. */
  9. function aggregator_requirements($phase) {
  10. $has_curl = function_exists('curl_init');
  11. $requirements = [];
  12. $requirements['curl'] = [
  13. 'title' => t('cURL'),
  14. 'value' => $has_curl ? t('Enabled') : t('Not found'),
  15. ];
  16. if (!$has_curl) {
  17. $requirements['curl']['severity'] = REQUIREMENT_ERROR;
  18. $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>.');
  19. }
  20. return $requirements;
  21. }
  22. /**
  23. * The simple presence of this update function clears cached field definitions.
  24. */
  25. function aggregator_update_8001() {
  26. // Feed ID base field is now required.
  27. }
  28. /**
  29. * Make the 'Source feed' field for aggregator items required.
  30. */
  31. function aggregator_update_8200() {
  32. // aggregator_update_8001() did not update the last installed field storage
  33. // definition for the aggregator item's 'Source feed' field.
  34. $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  35. $field_definition = $definition_update_manager->getFieldStorageDefinition('fid', 'aggregator_item');
  36. $field_definition->setRequired(TRUE);
  37. $definition_update_manager->updateFieldStorageDefinition($field_definition);
  38. }
  39. /**
  40. * Add a default value for the 'Refresh' field for aggregator feed entities.
  41. */
  42. function aggregator_update_8501() {
  43. $definition_update_manager = \Drupal::entityDefinitionUpdateManager();
  44. $field_definition = $definition_update_manager->getFieldStorageDefinition('refresh', 'aggregator_feed');
  45. $field_definition->setDefaultValue(3600);
  46. $definition_update_manager->updateFieldStorageDefinition($field_definition);
  47. }