66 */
77
88use Drupal\commerce\BundleFieldDefinition;
9+ use Drupal\commerce_product\Entity\ProductTypeInterface;
910use Drupal\Core\Access\AccessResult;
1011use Drupal\Core\Cache\Cache;
1112use Drupal\Core\Form\FormStateInterface;
@@ -36,8 +37,8 @@ function commerce_product_entity_form_display_update(EntityFormDisplayInterface
3637 * Implements hook_ENTITY_TYPE_update().
3738 */
3839function commerce_product_entity_view_display_update(EntityInterface $entity) {
39- // The product view uses the variation view and needs to be cleared, which doesn't happen automatically
40- // because we're editing the variation, not the product
40+ // The product view uses the variation view and needs to be cleared, which doesn't
41+ // happen automatically because we're editing the variation, not the product.
4142 if (substr($entity->getConfigTarget(), 0, 27) === 'commerce_product_variation.') {
4243 Cache::invalidateTags(['commerce_product_view']);
4344 }
@@ -177,7 +178,7 @@ function template_preprocess_commerce_product_attribute_value(array &$variables)
177178 * @param \Drupal\commerce_product\Entity\ProductTypeInterface $product_type
178179 * The product type.
179180 */
180- function commerce_product_add_stores_field($product_type) {
181+ function commerce_product_add_stores_field(ProductTypeInterface $product_type) {
181182 $field_definition = BundleFieldDefinition::create('entity_reference')
182183 ->setTargetEntityTypeId('commerce_product')
183184 ->setTargetBundle($product_type->id())
@@ -204,7 +205,7 @@ function commerce_product_add_stores_field($product_type) {
204205 * @param string $label
205206 * (optional) The label for the body instance. Defaults to 'Body'.
206207 */
207- function commerce_product_add_body_field($product_type, $label = 'Body') {
208+ function commerce_product_add_body_field(ProductTypeInterface $product_type, $label = 'Body') {
208209 $field_definition = BundleFieldDefinition::create('text_with_summary')
209210 ->setTargetEntityTypeId('commerce_product')
210211 ->setTargetBundle($product_type->id())
@@ -233,7 +234,7 @@ function commerce_product_add_body_field($product_type, $label = 'Body') {
233234 * @param \Drupal\commerce_product\Entity\ProductTypeInterface $product_type
234235 * The product type.
235236 */
236- function commerce_product_add_variations_field($product_type) {
237+ function commerce_product_add_variations_field(ProductTypeInterface $product_type) {
237238 $field_definition = BundleFieldDefinition::create('entity_reference')
238239 ->setTargetEntityTypeId('commerce_product')
239240 ->setTargetBundle($product_type->id())
0 commit comments