You are here

public function RulesConditionalPluginUI::operations in Conditional Rules 7

Same name and namespace in other branches
  1. 8 includes/rules_conditional.ui.inc \RulesConditionalPluginUI::operations()

Implements RulesPluginUIInterface.

Overrides RulesContainerPluginUI::operations

1 call to RulesConditionalPluginUI::operations()
RulesConditionalEmptyUI::operations in includes/rules_conditional.ui.inc
Implements RulesPluginUIInterface.
1 method overrides RulesConditionalPluginUI::operations()
RulesConditionalEmptyUI::operations in includes/rules_conditional.ui.inc
Implements RulesPluginUIInterface.

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