2015-05-19 22:49:00 +00:00
<?php
/**
* @file
* Install, update and uninstall functions for the rest module.
*/
/**
* Implements hook_requirements().
*/
function rest_requirements($phase) {
$requirements = array();
2015-05-29 15:15:31 +00:00
if (version_compare(PHP_VERSION, '5.6.0', '>=') && version_compare(PHP_VERSION, '7', '<') && ini_get('always_populate_raw_post_data') != -1) {
2015-05-19 22:49:00 +00:00
$requirements['always_populate_raw_post_data'] = array(
'title' => t('always_populate_raw_post_data PHP setting'),
'value' => t('Not set to -1.'),
'severity' => REQUIREMENT_ERROR,
2015-05-29 15:15:31 +00:00
'description' => t('The always_populate_raw_post_data PHP setting should be set to -1 in PHP version 5.6. Please check the <a href="https://php.net/manual/en/ini.core.php#ini.always-populate-raw-post-data">PHP manual</a> for information on how to correct this.'),
2015-05-19 22:49:00 +00:00
);
}
return $requirements;
}
Issue #2308745 by Alumei, dawehner, Wim Leers, larowlan, Arla, alexpott, g.oechsler, R.Muilwijk, Berdir, catch, klausi, clemens.tolboom, MattA, Crell: Remove rest.settings.yml, use rest_resource config entities
2016-06-19 13:41:10 +00:00
/**
* @defgroup updates-8.1.x-to-8.2.x
* @{
* Update functions from 8.1.x to 8.2.x.
*/
/**
* Install the REST config entity type and fix old settings-based config.
2016-07-26 21:57:39 +00:00
*
* @see rest_post_update_create_rest_resource_config_entities()
Issue #2308745 by Alumei, dawehner, Wim Leers, larowlan, Arla, alexpott, g.oechsler, R.Muilwijk, Berdir, catch, klausi, clemens.tolboom, MattA, Crell: Remove rest.settings.yml, use rest_resource config entities
2016-06-19 13:41:10 +00:00
*/
function rest_update_8201() {
\Drupal::entityDefinitionUpdateManager()->installEntityType(\Drupal::entityTypeManager()->getDefinition('rest_resource_config'));
\Drupal::state()->set('rest_update_8201_resources', \Drupal::config('rest.settings')->get('resources'));
\Drupal::configFactory()->getEditable('rest.settings')
->clear('resources')
->save();
}
Issue #2228141 by juampynr, eiriksm, dawehner, almaudoh, lokapujya, mohit_aghera, clemens.tolboom, manojapare, Lendude, Sonal.Sangale, Wim Leers, alexpott, damiankloip, andypost: Add authentication support to REST views
2016-06-25 13:33:37 +00:00
/**
* Re-save all views with a REST display to add new auth defaults.
*/
function rest_update_8202() {
$config_factory = \Drupal::configFactory();
foreach ($config_factory->listAll('views.view.') as $view_config_name) {
$save = FALSE;
$view = $config_factory->getEditable($view_config_name);
$displays = $view->get('display');
foreach ($displays as $display_name => &$display) {
if ($display['display_plugin'] == 'rest_export') {
if (!isset($display['display_options']['auth'])) {
$display['display_options']['auth'] = [];
$save = TRUE;
}
}
}
if ($save) {
$view->set('display', $displays);
$view->save(TRUE);
}
}
}
2016-08-01 16:35:53 +00:00
/**
* Enable BC for EntityResource: continue to use permissions.
*/
function rest_update_8203() {
$config_factory = \Drupal::configFactory();
$rest_settings = $config_factory->getEditable('rest.settings');
$rest_settings->set('bc_entity_resource_permissions', TRUE)
->save(TRUE);
}
Issue #2308745 by Alumei, dawehner, Wim Leers, larowlan, Arla, alexpott, g.oechsler, R.Muilwijk, Berdir, catch, klausi, clemens.tolboom, MattA, Crell: Remove rest.settings.yml, use rest_resource config entities
2016-06-19 13:41:10 +00:00
/**
* @} End of "defgroup updates-8.1.x-to-8.2.x".
*/