function share_everywhere_entity_extra_field_info in Share Everywhere 2.x
Same name and namespace in other branches
- 8 share_everywhere.module \share_everywhere_entity_extra_field_info()
Implements hook_entity_extra_field_info().
File
- ./
share_everywhere.module, line 100 - A module that adds social buttons to your website.
Code
function share_everywhere_entity_extra_field_info() {
$config = \Drupal::config('share_everywhere.settings');
$extra = [];
if ($config
->get('location') == 'content') {
$entity_info = \Drupal::service('entity_type.bundle.info')
->getAllBundleInfo();
if (isset($entity_info['node'])) {
foreach ($entity_info['node'] as $bundle => $bundle_info) {
$extra['node'][$bundle]['display'] = [
'share_everywhere' => [
'label' => t('Share Everywhere'),
'description' => t('Share Everywhere buttons'),
'weight' => $config
->get('weight'),
],
];
}
}
if (isset($entity_info['commerce_product'])) {
foreach ($entity_info['commerce_product'] as $bundle => $bundle_info) {
$extra['commerce_product'][$bundle]['display'] = [
'share_everywhere' => [
'label' => t('Share Everywhere'),
'description' => t('Share Everywhere buttons'),
'weight' => $config
->get('weight'),
],
];
}
}
}
return $extra;
}