You are here

function _required_by_role_get_instance in Required by role 7.2

Helper function to get an instance of the handler class.

2 calls to _required_by_role_get_instance()
required_by_role_field_widget_is_required in ./required_by_role.module
Function to find out if an element is required or not.
required_by_role_form_field_ui_field_edit_form_alter in ./required_by_role.module
Implements hook_form_FORM_ID_alter().

File

./required_by_role.module, line 162
Allows certain user roles to be exempt from required fields

Code

function _required_by_role_get_instance($id) {
  $instances =& drupal_static(__FUNCTION__);
  if (!isset($instances[$id])) {
    ctools_include('plugins');
    $plugin = ctools_get_plugins('required_by_role', 'required', $id);
    $class = ctools_plugin_get_class($plugin, 'handler');
    $instances[$id] = new $class();
  }

  // Check that plugin class has inherited proper 'RequiredPlugin' class.
  if (!$instances[$id] instanceof RequiredPlugin) {
    $instances[$id] = NULL;
  }
  return $instances[$id];
}