DeriverBase.php 759 B

1234567891011121314151617181920212223242526272829303132333435
  1. <?php
  2. namespace Drupal\Component\Plugin\Derivative;
  3. /**
  4. * Provides a basic deriver.
  5. */
  6. abstract class DeriverBase implements DeriverInterface {
  7. /**
  8. * List of derivative definitions.
  9. *
  10. * @var array
  11. */
  12. protected $derivatives = [];
  13. /**
  14. * {@inheritdoc}
  15. */
  16. public function getDerivativeDefinition($derivative_id, $base_plugin_definition) {
  17. if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) {
  18. return $this->derivatives[$derivative_id];
  19. }
  20. $this->getDerivativeDefinitions($base_plugin_definition);
  21. return $this->derivatives[$derivative_id];
  22. }
  23. /**
  24. * {@inheritdoc}
  25. */
  26. public function getDerivativeDefinitions($base_plugin_definition) {
  27. return $this->derivatives;
  28. }
  29. }