service_container.module 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <?php
  2. /**
  3. * @file
  4. * Main module file for the service_container module.
  5. */
  6. // -----------------------------------------------------------------------
  7. // Core Hooks
  8. /**
  9. * Implements hook_stream_wrappers_alter().
  10. */
  11. function service_container_stream_wrappers_alter(&$wrappers) {
  12. if (class_exists('ServiceContainer')) {
  13. ServiceContainer::init();
  14. }
  15. }
  16. /**
  17. * Implements hook_modules_enabled().
  18. */
  19. function service_container_modules_enabled() {
  20. if (class_exists('ServiceContainer')) {
  21. ServiceContainer::reset();
  22. ServiceContainer::init();
  23. }
  24. }
  25. /**
  26. * Implements hook_module_implements_alter().
  27. */
  28. function service_container_module_implements_alter(&$implementations, $hook) {
  29. // Moves our hook_init() implementation to occur first so that we
  30. // can initialize the container.
  31. if ($hook == 'stream_wrappers_alter') {
  32. $group = $implementations['service_container'];
  33. unset($implementations['service_container']);
  34. $implementations = array('service_container' => $group) + $implementations;
  35. }
  36. }
  37. // -----------------------------------------------------------------------
  38. // Contrib Hooks
  39. /**
  40. * Implements hook_ctools_plugin_type().
  41. */
  42. function service_container_ctools_plugin_type() {
  43. $items['ServiceProvider'] = array(
  44. 'cache' => FALSE,
  45. );
  46. return $items;
  47. }
  48. /**
  49. * Implements hook_ctools_plugin_directory().
  50. */
  51. function service_container_ctools_plugin_directory($owner, $plugin_type) {
  52. if ($owner == 'service_container') {
  53. return 'src/ServiceContainer/' . $plugin_type;
  54. }
  55. return NULL;
  56. }
  57. // -----------------------------------------------------------------------
  58. // Public API