annotate core/modules/aggregator/aggregator.install @ 19:fa3358dc1485 tip

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