The entity query factor was deprecated in Drupal 8.3.x, modules should get the query object from the relevant storage instead. Reference: https://www.drupal.org/node/2849874

Before: inject entity.query
After: Use entity_type.manager to get the storage, then call getQuery() on that.

Comments

bojanz created an issue. See original summary.

vasike’s picture

Status: Active » Needs review
StatusFileSize
new12.23 KB

here is patch for this.
I hope i didn't miss a thing about there.

I didn't make a PR as maybe the builds fail for 8.2

berdir’s picture

This works fine on 8.2, all the API's already existed, we just removed one additional wrapper, internally entity.query already used this method.

  1. +++ b/modules/product/src/Form/ProductVariationTypeDeleteForm.php
    @@ -13,36 +11,10 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
        */
       public function buildForm(array $form, FormStateInterface $form_state) {
    -    $variation_count = $this->queryFactory->get('commerce_product_variation')
    +    $variation_count = $this->entityTypeManager->getStorage('commerce_product_variation')->getQuery()
           ->condition('type', $this->entity->id())
           ->count()
           ->execute();
    

    sounds like this would be a nice case for a generic entity bundle delete form, you already have like three of those.

    And actually, what I'd like to have is one that allows to delete those with a batch and then returns to the delete confirmation page, instead of just denying it.

  2. +++ b/modules/product/src/ProductAttributeFieldManager.php
    @@ -220,7 +220,7 @@ class ProductAttributeFieldManager implements ProductAttributeFieldManagerInterf
         }
    -    $query = $this->queryFactory->get('commerce_product_variation')
    +    $query = $this->entityTypeManager->getStorage('commerce_product_variation')->getQuery()
           ->condition('type', $variation_type_id)
           ->exists($field_name)
           ->range(0, 1);
    

    yes, that's the only case when you possibly need to inject the entity type manager when you didn't before.. when you just need to do a count query.

vasike’s picture

@Berdir : thanks for your specs.

and there is the patch PR for this
https://github.com/drupalcommerce/commerce/pull/661

  • bojanz committed ba641c0 on 8.x-2.x authored by vasike
    Issue #2857357 by vasike, bojanz, Berdir: Replace entity.query usage (#...
bojanz’s picture

Status: Needs review » Fixed

sounds like this would be a nice case for a generic entity bundle delete form, you already have like three of those.

Good idea. This was not possible before because we didn't have the single/plural entity type labels.

I've committed vasike's current work and opened a followup to track this: #2859570: Create a generic entity bundle delete form.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.