Attached is a patch that adds a "captain hook" to Pirate, allowing other modules to add/alter the array of pattern replacements, like so:

/**
* Implementation of hook_captian().
*/
function mymodule_captain($patterns) {

$my_patterns = array(
'%\bDrupal\b%' => 'tha Drrupal',
'%\bcommunity\b%' => 'curmmunity',
'%\bplumbing\b%' => 'depths',
);
$patterns = array_merge($patterns, $my_patterns);
return $patterns;
}

CommentFileSizeAuthor
pirate-capitan_hook.patch873 bytesmlsamuelson
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jrglasgow’s picture

Status: Needs review » Needs work

mlsamuelson,

One thing you might want to add to your patch - documentation for the hook.


/**
 * Allow other modules to add their own patterns for replacement
 */
function hook_captain(&$patterns) {
  $my_patterns = array(
    '%\bDrupal\b%'    => 'tha Drrupal',
    '%\bcommunity\b%' => 'curmmunity',
    '%\bplumbing\b%'  => 'depths',
  );
  $patterns = array_merge($patterns, $my_patterns);
  return $patterns;
}

other than that it looks good.

sillygwailo’s picture

Status: Needs work » Needs review
sillygwailo’s picture

Status: Needs review » Fixed

Committed this to both the 6.x and 7.x branches. Do we need a return in the example? See the pirate.api.php I committed for reference.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

sillygwailo’s picture

The hook definitely needs a return, so I've updated the API docs accordingly.