You are here

public function SocialLinkWidget::__construct in Social Link Field 8

Constructs a WidgetBase object.

Parameters

string $plugin_id: The plugin_id for the widget.

mixed $plugin_definition: The plugin implementation definition.

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The definition of the field to which the widget is associated.

array $settings: The widget settings.

array $third_party_settings: Any third party settings.

Overrides WidgetBase::__construct

File

src/Plugin/Field/FieldWidget/SocialLinkWidget.php, line 55

Class

SocialLinkWidget
Plugin implementation of the 'open_hours' widget.

Namespace

Drupal\social_link_field\Plugin\Field\FieldWidget

Code

public function __construct($plugin_id, $plugin_definition, FieldDefinitionInterface $field_definition, array $settings, array $third_party_settings, $platforms_service, $route_match) {
  parent::__construct($plugin_id, $plugin_definition, $field_definition, $settings, $third_party_settings);
  $this->platforms = $platforms_service
    ->getPlatforms();

  // Limit available platforms to the field settings.
  if ($limited_platforms = $field_definition
    ->getSetting('platforms')) {
    if ($limited_platforms = array_filter($limited_platforms)) {
      $this->platforms = array_intersect_key($this->platforms, $limited_platforms);
    }
  }
  $this->routeName = $route_match
    ->getRouteName();
  $this->cardinality = $this->fieldDefinition
    ->getFieldStorageDefinition()
    ->getCardinality();
}