You are here

function FeedImportController::exportFeed in Feed Import 8

Export feed.

Parameters

string $feed: Feed ID

Return value

array Renderable array with a textarea containing the JSON used for an import.

1 string reference to 'FeedImportController::exportFeed'
feed_import.routing.yml in ./feed_import.routing.yml
feed_import.routing.yml

File

src/Controller/FeedImportController.php, line 28
Contains \Drupal\feed_import\Controller\FeedImportController.

Class

FeedImportController
Controller routines for feed_import routes.

Namespace

Drupal\feed_import\Controller

Code

function exportFeed($fid) {
  $feed = FeedImport::loadFeed($fid);
  unset($feed->id, $feed->last_run, $feed->last_run_duration, $feed->last_run_items, $feed->name, $feed->machine_name, $feed->cron_import);
  $opt = 0;
  if (defined('JSON_PRETTY_PRINT')) {
    $opt |= JSON_PRETTY_PRINT;
  }
  if (defined('JSON_UNESCAPED_SLASHES')) {
    $opt |= JSON_UNESCAPED_SLASHES;
  }
  $feed = json_encode($feed, $opt);
  return array(
    '#theme' => 'textarea',
    '#value' => $feed,
    '#rows' => 15,
  );
}