Community Documentation

Using restore hooks

Last updated February 21, 2013. Created by Orgun109uk on February 21, 2013.
Log in to edit this page.

Additional to the script files, theres a hook too allow a module to provide its own programatically generated restore script, using "hook_restore_scripts" and returning an array of restore scripts: Note that the properties of the operations required depends on the operation classes.

<?php
/**
* Implements hook_restore_scripts().
*/
function MY_MODULE_restore_scripts() {
 
$scripts = array();

 
$scripts['example_script_1'] = array(
   
// The title for the restore script.
   
'title' => 'MY MODULES SCRIPT #1',

   
// A description for the restore script.
   
'description' => 'The first restore script provided by MY MODULE.',

   
// An array of the operations, indexed by the operations classname.
   
'operations' => array(

     
// Some variables.
     
'RestoreVariableOperation' => array(

        array(
         
'name' => 'some_random_variable_name',
         
'value' => 'a random value.',
        ),

        array(
         
'name' => 'site_name',
         
'value' => 'The name of my site.',
        ),

        array(
         
'name' => 'clean_urls',
         
'value' => TRUE,
        ),

      ),

    ),
  );

 
$scripts['example_script_2'] = array(
  );

  return
$scripts;
}
?>

An example module is provided showing this usage, "restore_example_hook" in the module/examples folder.

Page status

No known problems

Log in to edit this page

About this page

Drupal version
Drupal 7.x
Keywords
Restore, Restore hooks

Site Building Guide

Drupal’s online documentation is © 2000-2013 by the individual contributors and can be used in accordance with the Creative Commons License, Attribution-ShareAlike 2.0. PHP code is distributed under the GNU General Public License. Comments on documentation pages are used to improve content and then deleted.
nobody click here