Skip to content

Instantly share code, notes, and snippets.

@juampynr
Last active December 26, 2015 13:42
Show Gist options
  • Save juampynr/55da77eecc507babed4d to your computer and use it in GitHub Desktop.
Save juampynr/55da77eecc507babed4d to your computer and use it in GitHub Desktop.
Drupal 8: Extract the data of the content view
<?php
/**
* Extracts the data stored in the database for the Content view.
*
* Usage: place this file at the root of a Drupal 8 project and then execute
* the following command:
*
* drush scr extract-view-data
*
* After running it, /tmp/view_data.txt will contain the data of the view.
*/
use \Drupal\Core\Database\Database;
$data = Database::getConnection('default')->query('select data from {config} where name = :name', array(':name' => 'views.view.content'))->fetchField();
$serialized_data = unserialize($data);
file_put_contents('/tmp/view_data.txt', print_r($serialized_data, TRUE));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment