entityconnect.api.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <?php
  2. /**
  3. * That file describes hooks provided by entityconnect.
  4. */
  5. /**
  6. * hook_entityconnect_exclude_forms_alter().
  7. *
  8. * Allow modules to alter the list of exclude forms.
  9. * If you don't want a specific forms to be proceeded, or if Entityconnect affects
  10. *
  11. * @param $exclude_forms
  12. * @return array of forms that not be proceeded.
  13. *
  14. * @see entityconnect_child_form_alter()
  15. */
  16. function hook_entityconnect_exclude_forms_alter(&$exclude_forms) {
  17. $exclude_forms = array(
  18. 'search_block_form',
  19. 'page_node_form'
  20. );
  21. }
  22. /**
  23. * hook_entityconnect_ref_fields_alter().
  24. *
  25. * Allow modules to add fields as able to be connect.
  26. * That will display the "add" and "edit" buttons.
  27. *
  28. * Following example shows how to add buttons for bean entity.
  29. *
  30. * @param $ref_fields
  31. */
  32. function hook_entityconnect_ref_fields_alter(&$ref_fields) {
  33. // We are parsing all fields.
  34. foreach (field_info_fields() as $id => $field) {
  35. // We want to be sure that bean fields are provided by entityreference module.
  36. if ($field['type'] == 'entityreference' && $field['module'] == 'entityreference') {
  37. $entity_reference_info = entityreference_get_selection_handler($field);
  38. $entity_type = $entity_reference_info->field['settings']['target_type'];
  39. // Check if the module is enabled.
  40. if (module_exists('bean_admin_ui')) {
  41. $entity_info = entity_get_info($entity_type);
  42. if (!empty($entity_info['module']) && $entity_info['module'] == 'bean') {
  43. // Check user access
  44. if (user_access('entityconnect add button') || user_access('entityconnect edit button')) {
  45. // Add field to the list.
  46. $ref_fields[$id] = $field;
  47. }
  48. }
  49. }
  50. }
  51. }
  52. }
  53. /**
  54. * hook_entityconnect_return_form_alter().
  55. *
  56. * Allow modules to specify returned values by widget.
  57. *
  58. * @param $datas
  59. *
  60. * $datas = array(
  61. * 'data' => $data,
  62. * 'widget_containter' => $widget_container,
  63. * 'widget_container_type' => $widget_container_type,
  64. * 'field_info' => $field_info,
  65. * 'language' => $language,
  66. * 'element_value' => NULL
  67. * );
  68. *
  69. * @return mixed $datas['element_value'] need to be set.
  70. *
  71. */
  72. function hook_entityconnect_return_form_alter(&$datas) {
  73. /**
  74. * $datas['data'] : The cached datas.
  75. * $datas['element_value'] : Defaut value to apply on field.
  76. */
  77. }
  78. /**
  79. * hook_entityconnect_child_form_alter().
  80. *
  81. * @param $datas
  82. */
  83. function hook_entityconnect_child_form_alter(&$datas) {}
  84. /**
  85. * hook_entityconnect_child_form_submit().
  86. *
  87. * @param $datas
  88. */
  89. function hook_entityconnect_child_form_submit(&$datas) {}
  90. /**
  91. * hook_entityconnect_reference_modules_list_alter().
  92. *
  93. * @param $datas
  94. */
  95. function hook_entityconnect_field_type_list_alter(&$datas) {}
  96. /**
  97. * hook_entityconnect_add_alter().
  98. *
  99. * @param $output
  100. */
  101. function hook_entityconnect_add_alter(&$output) {}
  102. /**
  103. * hook_entityconnect_edit_alter().
  104. *
  105. * @param $output
  106. */
  107. function hook_entityconnect_edit_alter(&$output) {}
  108. /**
  109. * hook_entityconnect_add_info().
  110. *
  111. * @param $cache_id
  112. */
  113. function hook_entityconnect_add_info($cache_id, $entity_type, $acceptable_types) {}
  114. /**
  115. * hook_entityconnect_add_info_alter().
  116. *
  117. * @param $add_info
  118. * @param $cache_id
  119. */
  120. function hook_entityconnect_add_info_alter(&$info, &$context) {}
  121. /**
  122. * hook_entityconnect_edit_info().
  123. *
  124. * @param $cache_id
  125. */
  126. function hook_entityconnect_edit_info($cache_id, $entity_type, $target_id) {}
  127. /**
  128. * hook_entityconnect_edit_info_alter().
  129. *
  130. * @param $add_info
  131. * @param $cache_id
  132. */
  133. function hook_entityconnect_edit_info_alter(&$add_info, &$cache_id, &$entity_type, &$target_id) {}
  134. /**
  135. * hook_entityconnect_field_attach_form_alter().
  136. *
  137. * @param $data
  138. */
  139. function hook_entityconnect_field_attach_form_alter(&$data) {}
  140. /**
  141. * hook_entityconnect_add_edit_button_submit_alter().
  142. *
  143. * @param $data
  144. */
  145. function hook_entityconnect_add_edit_button_submit_alter(&$data) {}