Guide to Standardized Hooks - The describe() Method

Introduction

The describe() method embeds hook action code attributes in your hook action code. This provides a programmatic means for the action code to express the developer's intended use of the hook. 

Basic usage

To use the describe() method, create a describe subroutine that returns the appropriate category, event, stage, and other attributes for themanage_hooks utility.

For more information, read our The manage_hooks Utility and Hook Action Code documentation.

The describe() method in Perl modules

In Perl modules, the describe() method must return a Perl array reference, which  must  contain one or more hash references. 

  • Each hash reference relates to one hookable action and creates a single entry for the Standardized Hooks database.
  • The hash reference must, at minimum, contain the categoryeventstageexectype, and hook descriptors.

The describe() method in scripts

Important:

Scripts must include argument evaluation in the hook action code in order to use the describe() method. When you register hooks with script hook action code, the manage_hooks utility calls the script with the --describe argument. 

In scripts, the describe() method must return a JSON-encoded string. When you decode the string, the JSON structure must be an array that contains one or more hashes, or associative arrays. 

  • Each hash reference relates to one hookable action and creates a single entry for the Standardized Hooks database.
  • The hash reference must, at minimum, contain the categoryeventstageexectype, and hook descriptors.

Make certain that the hook descriptor uses the correct method to invoke the script in order to perform the hookable action.

  • If the script is monolithic, and performs internal logic based on the context, provide the script's absolute path and filename.
  • If the script can parse input arguments via a shell argument array (for example, $argv or @argv), it should specify the absolute path and filename and the argument to switch to the proper code block.

 

  • 0 Users Found This Useful
Was this answer helpful?

Related Articles

The cPanel Interface

For  cPanel  &  WHM  version  58 Overview The cPanel interface is...

User Preferences

For cPanel & WHM version 58 Overview This document outlines how to access your cPanel...

Manage External Authentications

For cPanel & WHM version 58 Overview Manage credentials Additional documentation...

What is cPanelID?

In This Article:  Overview ServicesHow to get a cPanelID cPanelID External...

Guide to cPanel Interface Customization - cPanel Style Development

Introduction You can develop custom styles that modify the appearance of the cPanel interface....