Provide Feeds support

Created on 16 August 2021, over 3 years ago
Updated 6 February 2025, 2 months ago

Problem/Motivation

It would be great if Feeds module support could be added.

In my case, when I use Feeds to import nodes from CSV files, I'd like to be able to selectively disable Simple XML Sitemap for some of the nodes.

Proposed resolution

A Feeds target needs to be added in /src/Feeds/Target/SimpleSitemap.php. I'm not familiar with Simple XML Sitemap's internal logic, so I don't know what code needs to be added, but here's the basic idea:

<?php

namespace Drupal\simple_sitemap\Feeds\Target;

use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\feeds\FeedInterface;
use Drupal\feeds\Plugin\Type\Target\FieldTargetBase;

/**
 * Provides a generic field target.
 *
 * @FeedsTarget(
 *   id = "simple_sitemap",
 *   field_types = {
 *     "metatag"
 *  }
 * )
 */
class SimpleSitemap extends FieldTargetBase {

  /**
   * {@inheritdoc}
   */
  protected static function prepareTarget(FieldDefinitionInterface $field_definition) {

    return $definition;
  }

  /**
   * {@inheritdoc}
   */
  public function setTarget(FeedInterface $feed, EntityInterface $entity, $field_name, array $values) {
    if ($values = $this->prepareValues($values)) {
    }
  }

}

User interface changes

None. Feeds handles the UI based on the target.

API changes

None.

Data model changes

None.

Feature request
Status

Postponed

Version

4.0

Component

Code

Created by

🇯🇵Japan ptmkenny

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

Production build 0.71.5 2024