/** * Allow modules to add settings to field formatters provided by other modules. * * @param \Drupal\Core\Field\FormatterInterface $plugin * The instantiated field formatter plugin. * @param \Drupal\Core\Field\FieldDefinitionInterface $field_definition * The field definition. * @param $view_mode * The entity view mode. * @param array $form * The (entire) configuration form array. * @param array $form_state * The form state. * * @return array * Returns the form array to be built. * * @see \Drupal\field_ui\DisplayOverView. */ function hook_field_formatter_third_party_settings_form(\Drupal\Core\Field\FormatterInterface $plugin, \Drupal\Core\Field\FieldDefinitionInterface $field_definition, $view_mode, $form, $form_state) { $element = array(); // Add a 'my_setting' checkbox to the settings form for 'foo_formatter' field // formatters. if ($plugin->getPluginId() == 'foo_formatter') { $element['my_setting'] = array('#type' => 'checkbox', '#title' => t('My setting'), '#default_value' => $plugin->getThirdPartySetting('my_module', 'my_setting')); } return $element; }
/** * {@inheritdoc} */ public function onDependencyRemoval(array $dependencies) { $parent = parent::onDependencyRemoval($dependencies); $thumbnail = $this->thumbnailFormatter->onDependencyRemoval($dependencies); $video = $this->videoFormatter->onDependencyRemoval($dependencies); $this->setSetting('image_style', $this->thumbnailFormatter->getSetting('image_style')); return $parent || $thumbnail || $video; }
/** * {@inheritdoc} */ public function settingsForm(array $form, FormStateInterface $form_state) { $form += $this->thumbnailFormatter->settingsForm([], $form_state); $form += $this->videoFormatter->settingsForm([], $form_state); return $form; }