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