public function AddToCart::__construct in Commerce Cart Flyout 8
Constructs a new AddToCart object.
Parameters
string $plugin_id: The plugin_id for the formatter.
mixed $plugin_definition: The plugin implementation definition.
\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The definition of the field to which the formatter is associated.
array $settings: The formatter settings.
string $label: The formatter label display setting.
string $view_mode: The view mode.
array $third_party_settings: Any third party settings.
\Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager: The entity type manager.
\Drupal\Core\Routing\RouteMatchInterface $route_match: The route match.
\Symfony\Component\Serializer\Serializer $serializer: The serializer.
\Drupal\commerce_product\ProductVariationAttributeMapperInterface $attribute_mapper: The attribute mapper.
\Drupal\Core\Render\RendererInterface $renderer: The renderer.
\Drupal\commerce_product\ProductVariationFieldRendererInterface $variation_field_renderer: The variation field renderer.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
Overrides FormatterBase::__construct
File
- src/
Plugin/ Field/ FieldFormatter/ AddToCart.php, line 134
Class
- AddToCart
- Plugin implementation of the 'commerce_cart_flyout_add_to_cart' formatter.
Namespace
Drupal\commerce_cart_flyout\Plugin\Field\FieldFormatterCode
public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, $label, $view_mode, array $third_party_settings, EntityTypeManagerInterface $entity_type_manager, RouteMatchInterface $route_match, Serializer $serializer, ProductVariationAttributeMapperInterface $attribute_mapper, RendererInterface $renderer, ProductVariationFieldRendererInterface $variation_field_renderer) {
parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $label, $view_mode, $third_party_settings);
$this->variationStorage = $entity_type_manager
->getStorage('commerce_product_variation');
$this->routeMatch = $route_match;
$this->serializer = $serializer;
$this->attributeMapper = $attribute_mapper;
$this->renderer = $renderer;
$this->attributeValueViewBuilder = $entity_type_manager
->getViewBuilder('commerce_product_attribute_value');
$this->attributeValueStorage = $entity_type_manager
->getStorage('commerce_product_attribute_value');
$this->variationFieldRenderer = $variation_field_renderer;
$this->orderItemStorage = $entity_type_manager
->getStorage('commerce_order_item');
}