function domain_integration_get_domain_info in Domain Integration (Drupal 7) 8
Same name and namespace in other branches
- 7 domain_integration.module \domain_integration_get_domain_info()
Returns the domain property for an entity_type.
Parameters
string $name: Parameter to return
string $entity_type: Entity_type (implemented are 'site', 'node', 'user').
Return value
array Array with domain properties (integer or string).
See also
domain_integration_entity_property_info_alter
1 string reference to 'domain_integration_get_domain_info'
- domain_integration_entity_property_info_alter in ./
domain_integration.module - Implements hook_entity_property_info_alter().
File
- ./
domain_integration.module, line 98 - Domain Integration.
Code
function domain_integration_get_domain_info($data, array $options, $name, $entity_type, $info) {
// Property mapper (remove "domain_" from $name).
$domain_target_property = substr_replace($name, "", 0, 7);
// Fast forward if $entity_type is 'site'.
if ($entity_type == 'site') {
$domain = domain_get_domain();
return array(
$domain[$domain_target_property],
);
}
// Property that contains domain information for 'real' entity_types.
if ($entity_type == 'node') {
$domain_property = 'domains';
}
elseif ($entity_type == 'user') {
$domain_property = 'domain_user';
}
else {
$domain_property = NULL;
}
// Extract and return data.
$domains = array();
// Check SendToAll
if ($domain_target_property == 'domain_site') {
return $data->domain_site;
}
// Domain properties.
if (!empty($data->{$domain_property})) {
foreach ($data->{$domain_property} as $domain_id) {
$domain = domain_load($domain_id);
if (isset($domain[$domain_target_property])) {
$domains[] = $domain[$domain_target_property];
}
}
}
return $domains;
}