SocialSharingButtons.php in Better Social Sharing Buttons 8
File
src/Plugin/DsField/SocialSharingButtons.php
View source
<?php
namespace Drupal\better_social_sharing_buttons\Plugin\DsField;
use Drupal\ds\Plugin\DsField\DsFieldBase;
use Drupal\Core\Url;
class SocialSharingButtons extends DsFieldBase {
public function build() {
$items = [];
global $base_url;
$entity = $this
->entity();
$config = \Drupal::config('better_social_sharing_buttons.settings');
$items['page_url'] = Url::fromRoute('<current>', [], [
'absolute' => TRUE,
]);
$items['description'] = '';
$items['title'] = $entity
->get('title')->value;
$items['width'] = $config
->get('width') ?: '20px';
$items['height'] = $config
->get('height') ?: '20px';
$items['radius'] = $config
->get('radius') ?: '3px';
$items['facebook_app_id'] = $config
->get('facebook_app_id') ?: '';
$items['iconset'] = $config
->get('iconset') ?: 'social-icons--square';
$items['services'] = $config
->get('services') ?: [
'facebook' => 'facebook',
'twitter' => 'twitter',
'linkedin' => 'linkedin',
'googleplus' => 'googleplus',
'email' => 'email',
];
$items['base_url'] = $base_url;
return [
'#theme' => 'better_social_sharing_buttons',
'#items' => $items,
];
}
}