You are here

protected function EntityProcessorBase::removeFeedItemField in Feeds 8.3

Deletes the feeds_item field.

1 call to EntityProcessorBase::removeFeedItemField()
EntityProcessorBase::onFeedTypeDelete in src/Feeds/Processor/EntityProcessorBase.php
The feed type is being deleted.

File

src/Feeds/Processor/EntityProcessorBase.php, line 757

Class

EntityProcessorBase
Defines a base entity processor.

Namespace

Drupal\feeds\Feeds\Processor

Code

protected function removeFeedItemField() {
  $storage_in_use = FALSE;
  $instance_in_use = FALSE;
  foreach (FeedType::loadMultiple() as $feed_type) {
    if ($feed_type
      ->id() === $this->feedType
      ->id()) {
      continue;
    }
    $processor = $feed_type
      ->getProcessor();
    if (!$processor instanceof EntityProcessorInterface) {
      continue;
    }
    if ($processor
      ->entityType() === $this
      ->entityType()) {
      $storage_in_use = TRUE;
      if ($processor
        ->bundle() === $this
        ->bundle()) {
        $instance_in_use = TRUE;
        break;
      }
    }
  }
  if ($instance_in_use) {
    return;
  }

  // Delete the field instance.
  if ($config = FieldConfig::loadByName($this
    ->entityType(), $this
    ->bundle(), 'feeds_item')) {
    $config
      ->delete();
  }
  if ($storage_in_use) {
    return;
  }

  // Delte the field storage.
  if ($storage = FieldStorageConfig::loadByName($this
    ->entityType(), 'feeds_item')) {
    $storage
      ->delete();
  }
}