BundleItemOrderItemTable.php in Commerce Product Bundle 8
File
src/Plugin/Field/FieldFormatter/BundleItemOrderItemTable.php
View source
<?php
namespace Drupal\commerce_product_bundle\Plugin\Field\FieldFormatter;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FieldItemListInterface;
use Drupal\Core\Field\FormatterBase;
class BundleItemOrderItemTable extends FormatterBase {
public function viewElements(FieldItemListInterface $items, $langcode) {
$orderItem = $items
->getEntity();
$elements = [];
$elements[0] = [
'#type' => 'view',
'#name' => 'cbp_item_order_items_table',
'#arguments' => [
$orderItem
->id(),
],
'#embed' => TRUE,
];
return $elements;
}
public static function isApplicable(FieldDefinitionInterface $field_definition) {
$entity_type = $field_definition
->getTargetEntityTypeId();
$field_name = $field_definition
->getName();
return $entity_type == 'commerce_order_item' && $field_name == 'bundle_item_order_items';
}
}