Elgg  Version 1.12
relationships.php
Go to the documentation of this file.
1 <?php
18  if ($row instanceof \stdClass) {
19  return new \ElggRelationship($row);
20  }
21 
22  return false;
23 }
24 
32 function get_relationship($id) {
33  return _elgg_services()->relationshipsTable->get($id);
34 }
35 
45  return _elgg_services()->relationshipsTable->getRow($id);
46 }
47 
56  return _elgg_services()->relationshipsTable->delete($id);
57 
58 }
59 
73 function add_entity_relationship($guid_one, $relationship, $guid_two) {
74  return _elgg_services()->relationshipsTable->add($guid_one, $relationship, $guid_two);
75 }
76 
88 function check_entity_relationship($guid_one, $relationship, $guid_two) {
89  return _elgg_services()->relationshipsTable->check($guid_one, $relationship, $guid_two);
90 }
91 
103 function remove_entity_relationship($guid_one, $relationship, $guid_two) {
104  return _elgg_services()->relationshipsTable->remove($guid_one, $relationship, $guid_two);
105 }
106 
118 function remove_entity_relationships($guid, $relationship = "", $inverse_relationship = false, $type = '') {
119  return _elgg_services()->relationshipsTable->removeAll($guid, $relationship, $inverse_relationship, $type);
120 }
121 
131 function get_entity_relationships($guid, $inverse_relationship = false) {
132  return _elgg_services()->relationshipsTable->getAll($guid, $inverse_relationship);
133 }
134 
217  return _elgg_services()->relationshipsTable->getEntities($options);
218 }
219 
235 function elgg_get_entity_relationship_where_sql($column, $relationship = null,
236  $relationship_guid = null, $inverse_relationship = false) {
237  return _elgg_services()->relationshipsTable->getEntityRelationshipWhereSql(
238  $column, $relationship, $relationship_guid, $inverse_relationship);
239 }
240 
252  return elgg_list_entities($options, 'elgg_get_entities_from_relationship');
253 }
254 
266  return _elgg_services()->relationshipsTable->getEntitiesFromCount($options);
267 }
268 
280  return elgg_list_entities($options, 'elgg_get_entities_from_relationship_count');
281 }
282 
292 function _elgg_relationships_test($hook, $type, $tests) {
293  global $CONFIG;
294  $tests[] = $CONFIG->path . 'engine/tests/ElggRelationshipTest.php';
295  return $tests;
296 }
297 
298 
304  elgg_register_plugin_hook_handler('unit_test', 'system', '_elgg_relationships_test');
305 }
306 
307 return function(\Elgg\EventsService $events, \Elgg\HooksRegistrationService $hooks) {
308  $events->registerHandler('init', 'system', '_elgg_relationship_init');
309 };
get_relationship($id)
Get a relationship by its ID.
add_entity_relationship($guid_one, $relationship, $guid_two)
Create a relationship between two entities.
remove_entity_relationship($guid_one, $relationship, $guid_two)
Delete a relationship between two entities.
_elgg_relationships_test($hook, $type, $tests)
Register relationship unit tests.
$column
Definition: add.php:13
elgg_list_entities_from_relationship_count($options)
Returns a list of entities by relationship count.
$guid
Removes an admin notice.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
Definition: elgglib.php:717
remove_entity_relationships($guid, $relationship="", $inverse_relationship=false, $type= '')
Removes all relationships originating from a particular entity.
$options
Definition: index.php:14
_elgg_relationship_init()
Initialize the relationship library private.
get_entity_relationships($guid, $inverse_relationship=false)
Get all the relationships for a given GUID.
_elgg_services()
Definition: autoloader.php:14
global $CONFIG
elgg_get_entity_relationship_where_sql($column, $relationship=null, $relationship_guid=null, $inverse_relationship=false)
Returns SQL appropriate for relationship joins and wheres.
check_entity_relationship($guid_one, $relationship, $guid_two)
Check if a relationship exists between two entities.
elgg global
Pointer to the global context.
Definition: elgglib.js:12
$type
Definition: add.php:8
delete_relationship($id)
Delete a relationship by its ID.
elgg_list_entities_from_relationship(array $options=array())
Returns a viewable list of entities by relationship.
elgg_list_entities(array $options=array(), $getter= 'elgg_get_entities', $viewer= 'elgg_view_entity_list')
Returns a string of rendered entities.
Definition: entities.php:590
row_to_elggrelationship($row)
Convert a database row to a new .
elgg_get_entities_from_relationship_count(array $options=array())
Gets the number of entities by a the number of entities related to them in a particular way...
$row
elgg_get_entities_from_relationship($options)
Return entities matching a given query joining against a relationship.
_elgg_get_relationship_row($id)
Get a database row from the relationship table.
if(!$collection_name) $id
Definition: add.php:17