RRSSBDemoBlock.php in Ridiculously Responsive Social Sharing Buttons 8.2
File
src/Plugin/Block/RRSSBDemoBlock.php
View source
<?php
namespace Drupal\rrssb\Plugin\Block;
use Drupal\Core\Render\Element;
class RRSSBDemoBlock extends RRSSBBlock {
public function build() {
$config = $this
->getConfiguration();
$button_set = \Drupal::entityTypeManager()
->getStorage('rrssb_button_set')
->load($config['button_set']);
$form = \Drupal::service('entity.form_builder')
->getForm($button_set, "edit");
foreach (Element::children($form) as $key) {
if ($key != 'appearance' && $key != 'actions') {
unset($form[$key]);
}
}
unset($form['#submit']);
unset($form['actions']['delete']);
unset($form['actions']['submit']['#submit']);
$form['actions']['submit']['#value'] = $this
->t('Update');
$form['#attributes']['class'][] = 'rrssb-control';
$form['#attached']['library'][] = 'rrssb/demo';
return $form;
}
public function label() {
return $this
->t('RRSSB demo form');
}
}