Skip to content

Instantly share code, notes, and snippets.

@nadavoid
Last active August 29, 2015 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nadavoid/75f8dcd451e0c5375f63 to your computer and use it in GitHub Desktop.
Save nadavoid/75f8dcd451e0c5375f63 to your computer and use it in GitHub Desktop.
<?php
// Example of programmatically executing a patch process.
// @see https://api.drupal.org/api/drupal/includes!form.inc/function/batch_process/7
// @see https://www.drupal.org/node/873132
// @see pathauto_bulk_update_form_submit()
$callback = 'user_pathauto_bulk_update_batch_process';
$batch = array(
'title' => t('Bulk updating URL aliases'),
'operations' => array(
array('pathauto_bulk_update_batch_start', array()),
),
'finished' => 'pathauto_bulk_update_batch_finished',
'file' => drupal_get_path('module', 'pathauto') . '/pathauto.admin.inc',
);
$settings = (object) array(
'module' => 'node',
'token_type' => 'node',
'groupheader' => 'Content paths',
'patterndescr' => 'Pattern for content page paths',
'patterndefault' => 'content/[node:title]',
'batch_update_callback' => 'node_pathauto_bulk_update_batch_process',
'batch_file' => 'profiles/asi/modules/contrib/pathauto/pathauto.pathauto.inc',
'patternitems' => array(
'initiative' => 'Pattern for all Initiative Paths',
'news' => 'Pattern for all News Paths',
'page' => 'Pattern for all Page Paths',
'post' => 'Pattern for all Post Paths',
'shared_story' => 'Pattern for all Shared Story Paths',
),
);
$batch['operations'][] = array(
'pathauto_bulk_update_batch_process',
array($callback, $settings),
);
batch_set($batch);
$batch =& batch_get();
$batch['progressive'] = FALSE;
batch_process();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment