ConfigCrudEvent.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <?php
  2. namespace Drupal\Core\Config;
  3. use Symfony\Component\EventDispatcher\Event;
  4. /**
  5. * Wraps a configuration event for event listeners.
  6. */
  7. class ConfigCrudEvent extends Event {
  8. /**
  9. * Configuration object.
  10. *
  11. * @var \Drupal\Core\Config\Config
  12. */
  13. protected $config;
  14. /**
  15. * Constructs a configuration event object.
  16. *
  17. * @param \Drupal\Core\Config\Config $config
  18. * Configuration object.
  19. */
  20. public function __construct(Config $config) {
  21. $this->config = $config;
  22. }
  23. /**
  24. * Gets configuration object.
  25. *
  26. * @return \Drupal\Core\Config\Config
  27. * The configuration object that caused the event to fire.
  28. */
  29. public function getConfig() {
  30. return $this->config;
  31. }
  32. /**
  33. * Checks to see if the provided configuration key's value has changed.
  34. *
  35. * @param string $key
  36. * The configuration key to check if it has changed.
  37. *
  38. * @return bool
  39. */
  40. public function isChanged($key) {
  41. return $this->config->get($key) !== $this->config->getOriginal($key);
  42. }
  43. }