Problem/Motivation

Error on dev, test and prod when accessing URL admin/config/services/acquia-lift-publisher preventing us from testing Acquia Lift integration.

Drupal\Component\Plugin\Exception\PluginNotFoundException: The "commerce_subscription" plugin does not exist. Valid plugin IDs for Drupal\commerce_recurring\SubscriptionTypeManager are: product_variation, standalone, recurring_donation in Drupal\Core\Plugin\DefaultPluginManager->doGetDefinition() (line 53 of core/lib/Drupal/Component/Plugin/Discovery/DiscoveryTrait.php).

Comments

jwilson3 created an issue. See original summary.

jwilson3’s picture

Project: Commerce Recurring Framework » Acquia Lift Connector
Status: Active » Needs review
StatusFileSize
new1.01 KB

Moving this issue to the Lift issue queue.

The problem is that there are two ways to get bundles:

* Via entity api using $entity_type->getBundleEntityType();
* Via annotation using $entity_type->get('bundle_plugin_type');

Lift's ContentPublishingForm was not implemented to work with bundle_plugin_type, only getBundleEntityType(). And Commerce doesn't implement getBundleEntityType() for its entities and instead opts for using the annotations. Bojan explains their reasoning in #2817751: Create an API for bundle plugins.

Lift's ContentPublishingForm::buildForm() loads the bundles with:

$bundle_type = $entity_type->getBundleEntityType();
$bundles = $bundle_type ? $this->entityTypeManager->getStorage($bundle_type)->loadMultiple() : [$entity_type];

By default it gets the $entity_type (commerce_subscription). Then from Subscription::bundleFieldDefinitions() the plugin manager is trying to create an instance of that bundle (commerce_subscription) but that plugin id does not exist.

/** @var \Drupal\commerce_recurring\SubscriptionTypeManager $subscription_type_manager */
$subscription_type_manager = \Drupal::service('plugin.manager.commerce_subscription_type');

/** @var \Drupal\commerce_recurring\Plugin\Commerce\SubscriptionType\SubscriptionTypeInterface $subscription_type */
$subscription_type = $subscription_type_manager->createInstance($bundle);

Because Lift doesn't need to know about the commerce recurring subscription entity type, our workaround for now (PATCH attached) is to have ContentPublishingForm::buildForm() simply skip the entity types that use bundle_plugin_type with this code snippet:

if (!$entity_type->get('bundle_plugin_type')) {
  $bundle_type = $entity_type->getBundleEntityType();
  $bundles = $bundle_type ? $this->entityTypeManager->getStorage($bundle_type)->loadMultiple() : [$entity_type];
}

In our opinion, the proper solution would be for Acquia Lift engineering team to look into this issue more deeply to decide how to proceed, and either suggest a compatibility between getBundleEntityType() and bundle_plugin_type in a Drupal core issue, or probably more ideally in the short term, to add support for both methodologies in the acquia_lift module.

I'm marking as needs review, so other maintainers can review this, but probably ultimately it would go back to needs work.

japerry’s picture

Version: 8.x-1.x-dev » 8.x-4.x-dev

Moving to lift 4.x queue. Likely won't get fixed in the lift module, since the new acquia_perz module has rewritten most of this code.

japerry’s picture

Status: Needs review » Closed (won't fix)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.