Exemple #1
0
 /**
  * Deletes the feeds_item field.
  */
 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();
     }
 }
Exemple #2
0
 /**
  * Builds a standard list of feeds permissions for a given type.
  *
  * @param \Drupal\feeds\Entity\FeedType $feed_type
  *   The feed type object.
  *
  * @return array
  *   An array of permission names and descriptions.
  */
 protected function buildPermissions(FeedType $feed_type)
 {
     $args = ['%name' => $feed_type->label()];
     $id = $feed_type->id();
     return ["view {$id} feeds" => ['title' => $this->t('%name: View feeds', $args)], "create {$id} feeds" => ['title' => $this->t('%name: Create new feeds', $args)], "update {$id} feeds" => ['title' => $this->t('%name: Update existing feeds', $args)], "delete {$id} feeds" => ['title' => $this->t('%name: Delete feeds', $args)], "import {$id} feeds" => ['title' => $this->t('%name: Import feeds', $args)], "clear {$id} feeds" => ['title' => $this->t('%name: Delete feed items', $args)], "unlock {$id} feeds" => ['title' => $this->t('%name: Unlock feeds', $args), 'description' => $this->t('If a feed importation breaks for some reason, users with this permission can unlock it.')]];
 }