RRSSBBlock.php in Ridiculously Responsive Social Sharing Buttons 8.2
File
src/Plugin/Block/RRSSBBlock.php
View source
<?php
namespace Drupal\rrssb\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Form\FormStateInterface;
class RRSSBBlock extends BlockBase {
public function build() {
$config = $this
->getConfiguration();
return rrssb_get_buttons($config['button_set'], \Drupal::routeMatch()
->getParameter('node'), 'url.path');
}
public function label() {
return $this
->t('Share this content');
}
public function blockForm($form, FormStateInterface $form_state) {
$form = parent::blockForm($form, $form_state);
$config = $this
->getConfiguration();
$form['button_set'] = [
'#type' => 'select',
'#title' => $this
->t('Button set'),
'#options' => rrssb_button_set_names(),
'#description' => $this
->t('Select RRSSB button set to display.'),
'#default_value' => isset($config['button_set']) ? $config['button_set'] : '',
];
return $form;
}
public function blockSubmit($form, FormStateInterface $form_state) {
parent::blockSubmit($form, $form_state);
$values = $form_state
->getValues();
$this->configuration['button_set'] = $values['button_set'];
}
}