You are here

public static function BundleItemOrderItemInlineForm::populateTitle in Commerce Product Bundle 8

Entity builder: populates the bundle item order item title from the bundle item.

Parameters

string $entity_type: The entity type identifier.

\Drupal\commerce_product_bundle\Entity\BundleItemOrderItemInterface $order_item: The order item.

array $form: The complete form array.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

File

src/Form/BundleItemOrderItemInlineForm.php, line 71

Class

BundleItemOrderItemInlineForm
Defines the inline form for order items.

Namespace

Drupal\commerce_product_bundle\Form

Code

public static function populateTitle($entity_type, BundleItemOrderItemInterface $order_item, array $form, FormStateInterface $form_state) {

  /** @var \Drupal\commerce_product_bundle\Entity\BundleItemInterface $bundle_item */
  $bundle_item = $order_item
    ->getBundleItem();
  $bundle_item
    ->setCurrentVariation($order_item
    ->getPurchasedEntity());
  if ($order_item
    ->isNew()) {
    $order_item
      ->setTitle($bundle_item
      ->getTitle());
  }
}