Skip to content

Update all preprocess docblocks #484

@jenlampton

Description

@jenlampton

Initial PR for this issue: backdrop/backdrop#3113

The documentation we use for preprocess functions is inconsistent all over core. Drupal 8 adopted a new standard. Below are two examples of the documentation I'm proposing for Backdrop.

  1. When there are only a few variables (5 or fewer) provided to the template we should list them all in the docs for the preprocess function. For example:
/**
 * Prepares variables for block templates.
 *
 * @param $variables
 *   An array containing (but not limited to) the following:
 *   - content: The actual content of the block.
 *   - block: The block object being displayed.
 *
 * @see block.tpl.php
 */
function template_preprocess_block(&$variables) {
  1. When there are a lot of variables (6 or more) provided to the template (node, for example) we can point people to the template file where all available default variables should be listed. For example:
/**
 * Prepares variables for node templates.
 *
 * Most themes use their own copy of node.tpl.php. The default is located at
 * "core/modules/node/node.tpl.php". The full list of variables is documented
 * in that file.
 *
 * @param $variables
 *   An array containing, but not imited to, the following:
 *   - node: Full node entity. Contains data that may not be safe.
 *   - view_mode: View mode; for example, "full", or "teaser".
 *
 * @see node.tpl.php
 */
function template_preprocess_node(&$variables) {

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions