You are here

contextphp.module in Context PHP 6

Same filename and directory in other branches
  1. 7 contextphp.module

File

contextphp.module
View source
<?php

/**
 * Implementation of hook_context_registry().
 */
function contextphp_context_registry() {
  $registry = array();
  $registry['conditions'] = array(
    'php' => array(
      'title' => t('PHP code'),
      'plugin' => 'contextphp_condition_php',
    ),
  );
  $registry['reactions'] = array(
    'php' => array(
      'title' => t('PHP code'),
      'plugin' => 'contextphp_reaction_php',
    ),
  );
  return $registry;
}

/**
 * Implementation of hook_context_plugins().
 */
function contextphp_context_plugins() {
  $plugins = array();
  $plugins['contextphp_condition_php'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'contextphp') . '/plugins',
      'file' => 'contextphp_condition_php.inc',
      'class' => 'contextphp_condition_php',
      'parent' => 'context_condition',
    ),
  );
  $plugins['contextphp_reaction_php'] = array(
    'handler' => array(
      'path' => drupal_get_path('module', 'contextphp') . '/plugins',
      'file' => 'contextphp_reaction_php.inc',
      'class' => 'contextphp_reaction_php',
      'parent' => 'context_reaction',
    ),
  );
  return $plugins;
}

/**
 * Implementation of hook_init().
 */
function contextphp_init() {
  $map = context_condition_map();
  if (!empty($map['php']) && ($plugin = context_get_plugin('condition', 'php'))) {
    $plugin
      ->execute();
  }
  $map = context_reactions();
  if (!empty($map['php']) && ($plugin = context_get_plugin('reaction', 'php'))) {
    $plugin
      ->execute();
  }
}

Functions

Namesort descending Description
contextphp_context_plugins Implementation of hook_context_plugins().
contextphp_context_registry Implementation of hook_context_registry().
contextphp_init Implementation of hook_init().