You are here

public function GoogleAnalyticsCounterCustomFieldGenerator::gacDeleteField in Google Analytics Counter 8.3

Deletes the unchecked field configurations.

Parameters

\Drupal\node\NodeTypeInterface $type: A node type entity.

Return value

null|void

Throws

\Drupal\Core\Entity\EntityStorageException

Overrides GoogleAnalyticsCounterCustomFieldGeneratorInterface::gacDeleteField

See also

GoogleAnalyticsCounterConfigureTypesForm

1 call to GoogleAnalyticsCounterCustomFieldGenerator::gacDeleteField()
GoogleAnalyticsCounterCustomFieldGenerator::gacPreDeleteField in src/GoogleAnalyticsCounterCustomFieldGenerator.php
Prepares to delete the custom field and saves the configuration.

File

src/GoogleAnalyticsCounterCustomFieldGenerator.php, line 210

Class

GoogleAnalyticsCounterCustomFieldGenerator
Defines the Google Analytics Counter custom field generator.

Namespace

Drupal\google_analytics_counter

Code

public function gacDeleteField(NodeTypeInterface $type) {

  // Check if field exists on the content type.
  $content_type = $type
    ->id();
  $config = FieldConfig::loadByName('node', $content_type, 'field_google_analytics_counter');
  if (!isset($config)) {
    return NULL;
  }

  // Delete the field from the content type.
  FieldConfig::loadByName('node', $content_type, 'field_google_analytics_counter')
    ->delete();
}