You are here

protected function RulesAbstractPlugin::setUp in Rules 7.2

Overrides RulesExtendable::setUp

4 calls to RulesAbstractPlugin::setUp()
RulesAbstractPlugin::forceSetUp in includes/rules.core.inc
Forces the object to be setUp, this executes setUp() if not done yet.
RulesAbstractPlugin::import in includes/rules.core.inc
Applies the given export.
RulesAbstractPlugin::__construct in includes/rules.core.inc
RulesCondition::import in includes/rules.plugins.inc
Applies the given export.

File

includes/rules.core.inc, line 1520
Rules base classes and interfaces needed for any rule evaluation.

Class

RulesAbstractPlugin
Defines a common base class for so-called "Abstract Plugins" like actions.

Code

protected function setUp() {
  parent::setUp();
  if (isset($this->cache[$this->itemName . '_info'][$this->elementName])) {
    $this->info = $this->cache[$this->itemName . '_info'][$this->elementName];

    // Remember that the info has been correctly setup.
    // @see self::forceSetup()
    $this->infoLoaded = TRUE;

    // Register the defined class, if any.
    if (isset($this->info['class'])) {
      $this->faces['RulesPluginImplInterface'] = 'RulesPluginImplInterface';
      $face_methods = get_class_methods('RulesPluginImplInterface');
      $class_info = array(
        1 => $this->info['class'],
      );
      foreach ($face_methods as $method) {
        $this->facesMethods[$method] = $class_info;
      }
    }

    // Add in per-plugin implementation callbacks if any.
    if (!empty($this->info['faces_cache'])) {
      foreach ($this->info['faces_cache'] as $face => $data) {
        list($methods, $file_names) = $data;
        foreach ($methods as $method => $callback) {
          $this->facesMethods[$method] = $callback;
        }
        foreach ((array) $file_names as $method => $name) {
          $this->facesIncludes[$method] = array(
            'module' => $this->info['module'],
            'name' => $name,
          );
        }
      }

      // Invoke the info_alter callback, but only if it has been implemented.
      if ($this->facesMethods['info_alter'] != $this->itemInfo['faces_cache'][0]['info_alter']) {
        $this
          ->__call('info_alter', array(
          &$this->info,
        ));
      }
    }
  }
  elseif (!empty($this->itemInfo['faces_cache']) && function_exists($this->elementName)) {

    // We don't have any info, so just add the name as execution callback.
    $this
      ->override(array(
      'execute' => $this->elementName,
    ));
  }
}