TipPluginBase.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. <?php
  2. namespace Drupal\tour;
  3. use Drupal\Core\Plugin\PluginBase;
  4. /**
  5. * Defines a base tour item implementation.
  6. *
  7. * @see \Drupal\tour\Annotation\Tip
  8. * @see \Drupal\tour\TipPluginInterface
  9. * @see \Drupal\tour\TipPluginManager
  10. * @see plugin_api
  11. */
  12. abstract class TipPluginBase extends PluginBase implements TipPluginInterface {
  13. /**
  14. * The label which is used for render of this tip.
  15. *
  16. * @var string
  17. */
  18. protected $label;
  19. /**
  20. * Allows tips to take more priority that others.
  21. *
  22. * @var string
  23. */
  24. protected $weight;
  25. /**
  26. * The attributes that will be applied to the markup of this tip.
  27. *
  28. * @var array
  29. */
  30. protected $attributes;
  31. /**
  32. * {@inheritdoc}
  33. */
  34. public function id() {
  35. return $this->get('id');
  36. }
  37. /**
  38. * {@inheritdoc}
  39. */
  40. public function getLabel() {
  41. return $this->get('label');
  42. }
  43. /**
  44. * {@inheritdoc}
  45. */
  46. public function getWeight() {
  47. return $this->get('weight');
  48. }
  49. /**
  50. * {@inheritdoc}
  51. */
  52. public function getAttributes() {
  53. return $this->get('attributes') ?: [];
  54. }
  55. /**
  56. * {@inheritdoc}
  57. */
  58. public function get($key) {
  59. if (!empty($this->configuration[$key])) {
  60. return $this->configuration[$key];
  61. }
  62. }
  63. /**
  64. * {@inheritdoc}
  65. */
  66. public function set($key, $value) {
  67. $this->configuration[$key] = $value;
  68. }
  69. }