public function SocialSharePrivacy::build in Share Message 8
Creates the AddThis toolbar.
Parameters
array $context: The form structure.
$plugin_attributes: Custom plugin attributes.
Return value
array $build Returns the modified configuration form structure.
Overrides SharePluginInterface::build
File
- src/
Plugin/ sharemessage/ SocialSharePrivacy.php, line 64
Class
- SocialSharePrivacy
- SocialSharePrivacy plugin.
Namespace
Drupal\sharemessage\Plugin\sharemessageCode
public function build($context, $plugin_attributes) {
$attributes = new Attribute([
'class' => [
'socialshareprivacy',
],
]);
if ($plugin_attributes) {
$attributes['socialshareprivacy:url'] = $this->shareMessage
->getUrl($context);
$attributes['socialshareprivacy:title'] = $this->shareMessage
->getTokenizedField($this->shareMessage->title, $context);
$attributes['socialshareprivacy:description'] = $this->shareMessage
->getTokenizedField($this->shareMessage->message_long, $context);
}
// Add Social Share Privacy buttons.
$build = [
'#theme' => 'sharemessage_socialshareprivacy',
'#attributes' => $attributes,
'#attached' => [
'library' => [
'sharemessage/socialshareprivacy',
],
'drupalSettings' => [
'socialshareprivacy_config' => [
'services' => $this
->services(),
'url' => $this->shareMessage->share_url,
],
],
],
];
$cacheability_metadata = CacheableMetadata::createFromObject($this->socialSharePrivacyConfig);
$cacheability_metadata
->applyTo($build);
return $build;
}