Mercurial > hg > isophonics-drupal-site
diff core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php @ 0:4c8ae668cc8c
Initial import (non-working)
author | Chris Cannam |
---|---|
date | Wed, 29 Nov 2017 16:09:58 +0000 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/core/lib/Drupal/Component/Plugin/Derivative/DeriverBase.php Wed Nov 29 16:09:58 2017 +0000 @@ -0,0 +1,35 @@ +<?php + +namespace Drupal\Component\Plugin\Derivative; + +/** + * Provides a basic deriver. + */ +abstract class DeriverBase implements DeriverInterface { + + /** + * List of derivative definitions. + * + * @var array + */ + protected $derivatives = []; + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinition($derivative_id, $base_plugin_definition) { + if (!empty($this->derivatives) && !empty($this->derivatives[$derivative_id])) { + return $this->derivatives[$derivative_id]; + } + $this->getDerivativeDefinitions($base_plugin_definition); + return $this->derivatives[$derivative_id]; + } + + /** + * {@inheritdoc} + */ + public function getDerivativeDefinitions($base_plugin_definition) { + return $this->derivatives; + } + +}