You are here

class RulesConditionalPluginUI in Conditional Rules 8

Same name and namespace in other branches
  1. 7 includes/rules_conditional.ui.inc \RulesConditionalPluginUI

Base UI for providing customized operation links.

Hierarchy

Expanded class hierarchy of RulesConditionalPluginUI

1 string reference to 'RulesConditionalPluginUI'
rules_conditional_rules_plugin_info in ./rules_conditional.rules.inc
Implements hook_rules_plugin_info().

File

includes/rules_conditional.ui.inc, line 10
Plugin UI implementation.

View source
class RulesConditionalPluginUI extends RulesContainerPluginUI {
  public function operations() {
    $ops = parent::operations();
    $elementChildrenTypes = array();
    foreach ($this->element
      ->getIterator() as $element) {
      $plugin = $element
        ->plugin();
      $elementChildrenTypes[$plugin] = $plugin;
    }
    foreach (rules_fetch_data('plugin_info') as $plugin => $info) {

      // Remove operations as specified in the plugin info.
      $remove = FALSE;
      if (!empty($info['conditional single']) && isset($elementChildrenTypes[$plugin])) {
        $remove = TRUE;
      }
      elseif (!empty($info['conditional depends']) && !array_intersect($elementChildrenTypes, $info['conditional depends'])) {
        $remove = TRUE;
      }

      // Remove link.
      if ($remove) {
        unset($ops['#links']['add_' . $plugin]);
      }
    }
    return $ops;
  }

}

Members