abstract.inc

  1. nittany7 modules/contrib/entityreference/plugins/selection/abstract.inc
  2. nittany7 modules/contrib/entityreference/plugins/behavior/abstract.inc
  3. cis7 modules/contrib/entityreference/plugins/behavior/abstract.inc
  4. cis7 modules/contrib/entityreference/plugins/selection/abstract.inc
  5. mooc7 modules/contrib/entityreference/plugins/selection/abstract.inc
  6. mooc7 modules/contrib/entityreference/plugins/behavior/abstract.inc

Classes

Namesort descending Description
EntityReference_BehaviorHandler_Abstract An abstract implementation of EntityReference_BehaviorHandler.
EntityReference_BehaviorHandler_Broken A broken implementation of EntityReference_BehaviorHandler.

Interfaces

Namesort descending Description
EntityReference_BehaviorHandler Additional behaviors for a Entity Reference field.

File

modules/contrib/entityreference/plugins/behavior/abstract.inc
View source
  1. <?php
  2. /**
  3. * Additional behaviors for a Entity Reference field.
  4. *
  5. * Implementations that wish to provide an implementation of this should
  6. * register it using CTools' plugin system.
  7. */
  8. interface EntityReference_BehaviorHandler {
  9. /**
  10. * Constructor for the behavior.
  11. *
  12. * @param $behavior
  13. * The name of the behavior plugin.
  14. */
  15. public function __construct($behavior);
  16. /**
  17. * Alter the field schema.
  18. *
  19. * @see hook_field_schema()
  20. */
  21. public function schema_alter(&$schema, $field);
  22. /**
  23. * Alter the properties information of a field instance.
  24. *
  25. * @see entity_hook_field_info()
  26. */
  27. public function property_info_alter(&$info, $entity_type, $field, $instance, $field_type);
  28. /**
  29. * Alter the views data of a field.
  30. *
  31. * @see entityreference_field_views_data()
  32. */
  33. public function views_data_alter(&$data, $field);
  34. /**
  35. * Act on loading entity reference fields of entities.
  36. *
  37. * @see hook_field_load()
  38. */
  39. public function load($entity_type, $entities, $field, $instances, $langcode, &$items);
  40. /**
  41. * Alter the empty status of a field item.
  42. *
  43. * @see hook_field_is_empty()
  44. */
  45. public function is_empty_alter(&$empty, $item, $field);
  46. /**
  47. * Act on validating an entity reference field.
  48. *
  49. * @see hook_field_validate()
  50. */
  51. public function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors);
  52. /**
  53. * Act on presaving an entity reference field.
  54. *
  55. * @see hook_field_presave()
  56. */
  57. public function presave($entity_type, $entity, $field, $instance, $langcode, &$items);
  58. /**
  59. * Act before inserting an entity reference field.
  60. *
  61. * @see hook_field_insert()
  62. */
  63. public function insert($entity_type, $entity, $field, $instance, $langcode, &$items);
  64. /**
  65. * Act after inserting an entity reference field.
  66. *
  67. * @see hook_field_attach_insert()
  68. */
  69. public function postInsert($entity_type, $entity, $field, $instance);
  70. /**
  71. * Act before updating an entity reference field.
  72. *
  73. * @see hook_field_update()
  74. */
  75. public function update($entity_type, $entity, $field, $instance, $langcode, &$items);
  76. /**
  77. * Act after updating an entity reference field.
  78. *
  79. * @see hook_field_attach_update()
  80. */
  81. public function postUpdate($entity_type, $entity, $field, $instance);
  82. /**
  83. * Act before deleting an entity with an entity reference field.
  84. *
  85. * @see hook_field_delete()
  86. */
  87. public function delete($entity_type, $entity, $field, $instance, $langcode, &$items);
  88. /**
  89. * Act after deleting an entity with an entity reference field.
  90. *
  91. * @see hook_field_attach_delete()
  92. */
  93. public function postDelete($entity_type, $entity, $field, $instance);
  94. /**
  95. * Act after inserting an entity.
  96. *
  97. * @see hook_entity_insert()
  98. */
  99. public function entityPostInsert($entity_type, $entity, $field, $instance);
  100. /**
  101. * Act after updating an entity.
  102. *
  103. * @see hook_entity_update()
  104. */
  105. public function entityPostUpdate($entity_type, $entity, $field, $instance);
  106. /**
  107. * Act after deleting an entity.
  108. *
  109. * @see hook_entity_delete()
  110. */
  111. public function entityPostDelete($entity_type, $entity, $field, $instance);
  112. /**
  113. * Generate a settings form for this handler.
  114. */
  115. public function settingsForm($field, $instance);
  116. /**
  117. * Determine if handler should appear.
  118. */
  119. public function access($field, $instance);
  120. }
  121. /**
  122. * An abstract implementation of EntityReference_BehaviorHandler.
  123. */
  124. abstract class EntityReference_BehaviorHandler_Abstract implements EntityReference_BehaviorHandler {
  125. /**
  126. * The name of the behavior plugin.
  127. */
  128. protected $behavior;
  129. /**
  130. * The plugin definition.
  131. */
  132. protected $plugin;
  133. public function __construct($behavior) {
  134. $this->behavior = $behavior;
  135. ctools_include('plugins');
  136. $plugin = ctools_get_plugins('entityreference', 'behavior', $behavior);
  137. $this->plugin = $plugin;
  138. }
  139. public function schema_alter(&$schema, $field) {}
  140. public function property_info_alter(&$info, $entity_type, $field, $instance, $field_type) {}
  141. public function views_data_alter(&$data, $field) {}
  142. public function load($entity_type, $entities, $field, $instances, $langcode, &$items) {}
  143. public function is_empty_alter(&$empty, $item, $field) {}
  144. public function validate($entity_type, $entity, $field, $instance, $langcode, $items, &$errors) {}
  145. public function presave($entity_type, $entity, $field, $instance, $langcode, &$items) {}
  146. public function insert($entity_type, $entity, $field, $instance, $langcode, &$items) {}
  147. public function postInsert($entity_type, $entity, $field, $instance) {}
  148. public function update($entity_type, $entity, $field, $instance, $langcode, &$items) {}
  149. public function postUpdate($entity_type, $entity, $field, $instance) {}
  150. public function delete($entity_type, $entity, $field, $instance, $langcode, &$items) {}
  151. public function postDelete($entity_type, $entity, $field, $instance) {}
  152. public function entityPostInsert($entity_type, $entity, $field, $instance) {}
  153. public function entityPostUpdate($entity_type, $entity, $field, $instance) {}
  154. public function entityPostDelete($entity_type, $entity, $field, $instance) {}
  155. public function settingsForm($field, $instance) {}
  156. public function access($field, $instance) {
  157. return TRUE;
  158. }
  159. }
  160. /**
  161. * A broken implementation of EntityReference_BehaviorHandler.
  162. */
  163. class EntityReference_BehaviorHandler_Broken extends EntityReference_BehaviorHandler_Abstract {
  164. public function settingsForm($field, $instance) {
  165. $form['behavior_handler'] = array(
  166. '#markup' => t('The selected behavior handler is broken.'),
  167. );
  168. return $form;
  169. }
  170. }