You are here

public function RulesConditionalPluginUI::operations in Conditional Rules 8

Same name and namespace in other branches
  1. 7 includes/rules_conditional.ui.inc \RulesConditionalPluginUI::operations()
1 call to RulesConditionalPluginUI::operations()
RulesConditionalEmptyUI::operations in includes/rules_conditional.ui.inc
1 method overrides RulesConditionalPluginUI::operations()
RulesConditionalEmptyUI::operations in includes/rules_conditional.ui.inc

File

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

Class

RulesConditionalPluginUI
Base UI for providing customized operation links.

Code

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;
}