gdpr_entity_property.inc in General Data Protection Regulation 7
File
modules/gdpr_fields/plugins/gdpr_data/gdpr_entity_property.inc
View source
<?php
$plugin = array(
'has menu' => FALSE,
'handler' => array(
'class' => 'gdpr_entity_property',
),
'get child' => 'gdpr_fields_gdpr_entity_property_get_child',
'get children' => 'gdpr_fields_gdpr_entity_property_get_children',
);
function gdpr_fields_gdpr_entity_property_get_child(array $plugin, $parent, $child) {
$plugins = gdpr_fields_gdpr_entity_property_get_children($plugin, $parent);
return $plugins[$parent . ':' . $child];
}
function gdpr_fields_gdpr_entity_property_get_children(array $plugin, $parent) {
$plugins = array();
foreach (entity_get_property_info() as $entity_type => $property_info) {
if (isset($property_info['bundles'])) {
$bundles = array_keys($property_info['bundles']);
}
else {
$bundles = array(
$entity_type,
);
}
foreach ($bundles as $bundle) {
$properties = array();
foreach ($property_info['properties'] as $property_name => $property) {
$name = "{$entity_type}|{$bundle}|{$property_name}";
$properties[$name] = $property;
}
if (isset($property_info['bundles'][$bundle])) {
foreach ($property_info['bundles'][$bundle]['properties'] as $property_name => $property) {
$name = "{$entity_type}|{$bundle}|{$property_name}";
$properties[$name] = $property;
}
}
foreach ($properties as $name => $property) {
$child_plugin = $plugin;
$child_plugin['name'] = $name;
$child_plugin['label'] = $property['label'];
$child_plugin['description'] = isset($property['description']) ? $property['description'] : '';
if (!empty($property['computed'])) {
$child_plugin['computed'] = TRUE;
}
$plugins[$name] = $child_plugin;
}
}
}
return $plugins;
}