features.module 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. /**
  3. * @file
  4. * Main hooks for Features module.
  5. */
  6. use Drupal\Core\Routing\RouteMatchInterface;
  7. /**
  8. * Implements hook_help().
  9. */
  10. function features_help($route_name, RouteMatchInterface $route_match) {
  11. switch ($route_name) {
  12. case 'help.page.features':
  13. $output = '';
  14. $output .= '<h3>' . t('About') . '</h3>';
  15. $output .= '<p>' . t('The Features module provides a user interface for exporting bundles of configuration into modules. For more information, see the online documentation for <a href=":url">Features module</a>', [
  16. ':url' => 'http://drupal.org/node/2404427',
  17. ]) . '</p>';
  18. return $output;
  19. }
  20. }
  21. /**
  22. * Implements hook_file_download().
  23. */
  24. function features_file_download($uri) {
  25. $scheme = file_uri_scheme($uri);
  26. $target = file_uri_target($uri);
  27. if ($scheme == 'temporary' && $target) {
  28. $request = \Drupal::request();
  29. $route = $request->attributes->get('_route');
  30. // Check if we were called by Features download route.
  31. // No additional access checking needed here: route requires
  32. // "export configuration" permission, token is validated by the controller.
  33. // @see \Drupal\features\Controller\FeaturesController::downloadExport()
  34. if ($route == 'features.export_download') {
  35. return [
  36. 'Content-disposition' => 'attachment; filename="' . $target . '"',
  37. ];
  38. }
  39. }
  40. }
  41. /**
  42. * Implements hook_modules_installed().
  43. */
  44. function features_modules_installed($modules) {
  45. if (!in_array('features', $modules)) {
  46. /** @var \Drupal\features\FeaturesAssignerInterface $assigner */
  47. $assigner = \Drupal::service('features_assigner');
  48. $assigner->purgeConfiguration();
  49. }
  50. }