You are here

public function EntityShareMetatagEnhancer::getSettingsForm in Entity Share 8.3

Same name and namespace in other branches
  1. 8.2 src/Plugin/jsonapi/FieldEnhancer/EntityShareMetatagEnhancer.php \Drupal\entity_share\Plugin\jsonapi\FieldEnhancer\EntityShareMetatagEnhancer::getSettingsForm()

File

src/Plugin/jsonapi/FieldEnhancer/EntityShareMetatagEnhancer.php, line 140

Class

EntityShareMetatagEnhancer
Prepare metatag value to be able to shared.

Namespace

Drupal\entity_share\Plugin\jsonapi\FieldEnhancer

Code

public function getSettingsForm(array $resource_field_info) {
  $settings = empty($resource_field_info['enhancer']['settings']) ? $this
    ->getConfiguration() : $resource_field_info['enhancer']['settings'];
  return [
    'expose_default_tags' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Expose default tags'),
      '#description' => $this
        ->t('Expose tags that have a default value, usually with tokens, and are not overridden in the entity.'),
      '#default_value' => $settings['expose_default_tags'],
    ],
    'replace_tokens' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Replace tokens'),
      '#description' => $this
        ->t('Replace tokens by its value.'),
      '#default_value' => $settings['replace_tokens'],
      '#states' => [
        'visible' => [
          ':input[name="resourceFields[' . $resource_field_info['fieldName'] . '][enhancer][settings][expose_default_tags]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ],
    'clear_tokens' => [
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Clear tokens'),
      '#description' => $this
        ->t('Remove tokens from the final text if no replacement value can be generated.'),
      '#default_value' => $settings['clear_tokens'],
      '#states' => [
        'visible' => [
          ':input[name="resourceFields[' . $resource_field_info['fieldName'] . '][enhancer][settings][expose_default_tags]"]' => [
            'checked' => TRUE,
          ],
          ':input[name="resourceFields[' . $resource_field_info['fieldName'] . '][enhancer][settings][replace_tokens]"]' => [
            'checked' => TRUE,
          ],
        ],
      ],
    ],
  ];
}