HeartbeatBlockDeriver.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. <?php
  2. namespace Drupal\heartbeat\Plugin\Derivative;
  3. use Drupal\Component\Plugin\Derivative\DeriverBase;
  4. use Drupal\Core\Plugin\ContainerFactoryPluginInterface;
  5. use Drupal\Core\Plugin\Discovery\ContainerDeriverInterface;
  6. use Symfony\Component\DependencyInjection\ContainerInterface;
  7. use Drupal\heartbeat\HeartbeatTypeServices;
  8. use Drupal\heartbeat\HeartbeatStreamServices;
  9. use Drupal\heartbeat\HeartbeatService;
  10. /**
  11. * Provides a block plugin definitions for Heartbeat
  12. *
  13. */
  14. class HeartbeatBlockDeriver extends DeriverBase implements ContainerDeriverInterface {
  15. /**
  16. * Drupal\heartbeat\HeartbeatTypeServices definition.
  17. *
  18. * @var \Drupal\heartbeat\HeartbeatTypeServices
  19. */
  20. protected $heartbeatTypeService;
  21. /**
  22. * Drupal\heartbeat\HeartbeatStreamServices definition.
  23. *
  24. * @var \Drupal\heartbeat\HeartbeatStreamServices
  25. */
  26. protected $heartbeatStreamService;
  27. /**
  28. * Drupal\heartbeat\HeartbeatService definition.
  29. *
  30. * @var \Drupal\heartbeat\HeartbeatService
  31. */
  32. protected $heartbeatService;
  33. /**
  34. * Construct.
  35. *
  36. * @param array $configuration
  37. * A configuration array containing information about the plugin instance.
  38. * @param string $plugin_id
  39. * The plugin_id for the plugin instance.
  40. * @param string $plugin_definition
  41. * The plugin implementation definition.
  42. */
  43. public function __construct(
  44. $plugin_id,
  45. HeartbeatTypeServices $heartbeat_heartbeattype,
  46. HeartbeatStreamServices $heartbeatstream,
  47. HeartbeatService $heartbeat
  48. ) {
  49. parent::__construct($plugin_id);
  50. $this->heartbeatTypeService = $heartbeat_heartbeattype;
  51. $this->heartbeatStreamServices = $heartbeatstream;
  52. $this->heartbeatService = $heartbeat;
  53. }
  54. /**
  55. * {@inheritdoc}
  56. */
  57. public static function create(ContainerInterface $container, $plugin_id) {
  58. return new static(
  59. $plugin_id,
  60. $container->get('heartbeat.heartbeattype'),
  61. $container->get('heartbeatstream'),
  62. $container->get('heartbeat')
  63. );
  64. }
  65. /**
  66. * {@inheritdoc}
  67. */
  68. public function build() {
  69. $build = [];
  70. $build['heartbeat_block']['#markup'] = 'Implement HeartbeatBlock.';
  71. return $build;
  72. }
  73. public function getDerivativeDefinitions($base_plugin_definition) {
  74. $def2 = parent::getDerivativeDefinitions($base_plugin_definition);
  75. return $base_plugin_definition;
  76. }
  77. }