diff --git a/src/Entity/License.php b/src/Entity/License.php index ddef5f6..52b222f 100644 --- a/src/Entity/License.php +++ b/src/Entity/License.php @@ -139,11 +139,17 @@ class License extends ContentEntityBase implements LicenseInterface { /** * {@inheritdoc} */ - public static function getWorkflowId($license) { + public function getTypePlugin() { /** @var LicenseTypeManager $license_type_manager */ $license_type_manager = \Drupal::service('plugin.manager.commerce_license_type'); - $license_type = $license_type_manager->createInstance($license->type); - return $license_type->getWorkflowId(); + return $license_type_manager->createInstance($this->type); + } + + /** + * {@inheritdoc} + */ + public static function getWorkflowId($license) { + return $license->getTypePlugin()->getWorkflowId(); } /** diff --git a/src/Entity/LicenseInterface.php b/src/Entity/LicenseInterface.php index 8832d13..7fba6d9 100644 --- a/src/Entity/LicenseInterface.php +++ b/src/Entity/LicenseInterface.php @@ -2,10 +2,7 @@ namespace Drupal\commerce_license\Entity; -use Drupal\Core\Entity\RevisionLogInterface; -use Drupal\Core\Entity\RevisionableInterface; -use Drupal\Component\Utility\Xss; -use Drupal\Core\Url; +use Drupal\commerce_license\Plugin\Commerce\LicenseType\LicenseTypeInterface; use Drupal\Core\Entity\EntityChangedInterface; use Drupal\user\EntityOwnerInterface; @@ -38,6 +35,13 @@ interface LicenseInterface extends EntityChangedInterface, EntityOwnerInterface public function setCreatedTime($timestamp); /** + * Get an instance of the associated license type plugin. + * + * @return LicenseTypeInterface + */ + public function getTypePlugin(); + + /** * Gets the workflow ID for the state field. * * @param \Drupal\commerce_license\Entity\LicenseInterface $license