You are here

public static function AddToCartItem::propertyDefinitions in Basic cart 8.4

Same name and namespace in other branches
  1. 8.6 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()
  2. 8 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()
  3. 8.0 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()
  4. 8.2 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()
  5. 8.3 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()
  6. 8.5 src/Plugin/Field/FieldType/AddToCartItem.php \Drupal\basic_cart\Plugin\Field\FieldType\AddToCartItem::propertyDefinitions()

Defines field item properties.

Properties that are required to constitute a valid, non-empty item should be denoted with \Drupal\Core\TypedData\DataDefinition::setRequired().

Return value

\Drupal\Core\TypedData\DataDefinitionInterface[] An array of property definitions of contained properties, keyed by property name.

Overrides FieldItemInterface::propertyDefinitions

See also

\Drupal\Core\Field\BaseFieldDefinition

File

src/Plugin/Field/FieldType/AddToCartItem.php, line 51

Class

AddToCartItem
Plugin implementation of the 'addtocart' field type.

Namespace

Drupal\basic_cart\Plugin\Field\FieldType

Code

public static function propertyDefinitions(FieldStorageDefinitionInterface $field_definition) {
  $config = Utility::cartSettings();
  $properties['value'] = DataDefinition::create('boolean')
    ->setLabel(t($config
    ->get('add_to_cart_button')));

  // $properties['no_ui'] = TRUE;.
  return $properties;
}