Open main menu

Extension:Push/hooks

PushAPIBeforePushEdit

Since Push version 0.7.

Hook that allows modifying (or aborting) a push before it is executed.

Example usage:

$wgHooks['PushAPIBeforePush'][] = 'efYourPushHook';

/**
 * Hook that allows modifying (or aborting) the push before it is executed.
 * 
 * @param Title $title Title object of the page that will be pushed
 * @param array $revision Array holding data about the latest revision of the page to be pushed
 * @param string $target The target apis url
 * @param string $token The edit token needed to do the push
 * @param boolean $doPush Allows aborting the push by settings this to false
 */
function efYourPushHook( Title &$title, array &$revision, &$target, &$token, &$doPush ) {
	// Replaces 'Awesome' and 'awesome' by their upper-case equivalent on the target wiki. 
	$revision['*'] = str_replace( array( 'Awesome', 'awesome' ), 'AWESOME', $revision['*'] );
	return true;
}

PushAPIAfterPushEdit

Since Push version 1.1.

Hook that allows doing actions after the completion of a push.

Example usage:

$wgHooks['PushAPIAfterPush'][] = 'efYourPushHook';

/**
 * Hook that allows doing actions after the completion of a push.
 * 
 * @param Title $title Title object of the page that will be pushed
 * @param array $revision Array holding data about the latest revision of the page to be pushed
 * @param string $target The target apis url
 * @param string $token The edit token needed to do the push
 * @param string $response The (JSON) response of the call to the remote API.
 */
function efYourPushHook( Title $title, array $revision, $target, $token, $response ) {
	// Do something here
	return true;
}

PushAPIBeforeImagePushEdit

Since Push version 0.7.

Hook that allows modifying (or aborting) an image push before it is executed.

Example usage:

$wgHooks['PushAPIBeforeImagePush'][] = 'efYourPushHook';

/**
 * Hook that allows modifying (or aborting) the image push before it is executed.
 * 
 * @param Title $title Title object of the page that will be pushed
 * @param string $target The target apis url
 * @param string $token The edit token needed to do the push
 * @param boolean $doPush Allows aborting the push by settings this to false
 */
function efYourPushHook( Title &$title, &$target, &$token, &$doPush ) {
	// Do something here
	return true;
}

PushAPIAfterImagePushEdit

Since Push version 1.1.

Hook that allows doing actions after the completion of an image push.

Example usage:

$wgHooks['PushAPIAfterImagePush'][] = 'efYourPushHook';

/**
 * Hook that allows doing actions after the completion of an image push.
 * 
 * @param Title $title Title object of the page that will be pushed
 * @param string $target The target apis url
 * @param string $token The edit token needed to do the push
 * @param string $response The (JSON) response of the call to the remote API.
 */
function efYourPushHook( Title $title $target, $token, $response ) {
	// Do something here
	return true;
}