ShareThis.php in Sharethis block 8
File
src/Plugin/Block/ShareThis.php
View source
<?php
namespace Drupal\sharethis_block\Plugin\Block;
use Drupal\Core\Block\BlockBase;
use Drupal\Core\Config\ConfigFactoryInterface;
use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
class ShareThis extends BlockBase implements ContainerFactoryPluginInterface {
protected $config;
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config_factory) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->config = $config_factory
->get('sharethis_block.configuration');
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
return new static($configuration, $plugin_id, $plugin_definition, $container
->get('config.factory'));
}
public function build() {
if ($this->config
->get('sharethis_inline')) {
$build['buttons'] = [
'#markup' => '<div class="sharethis-inline-share-buttons"></div>',
];
}
$build['#attached']['library'][] = 'sharethis_block/sharethis.core';
return $build;
}
}
Classes
Name |
Description |
ShareThis |
Provides a 'ShareThis' block which just loads javascript for the widget. |