Commit 61eda72e authored by Marco Villegas's avatar Marco Villegas
Browse files

Issue #1548006: Let backends define default plugins.

Actually the general way of doing it should pass also the entity used, but I am
assuming here that we will not be naming two plugin types in different entities
with the same name :-)
parent d6cb4ff7
Loading
Loading
Loading
Loading
+14 −0
Changes for includes/VersioncontrolBackend.php: 14 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -290,4 +290,18 @@ abstract class VersioncontrolBackend {
    return TRUE;
  }

  /**
   * Retrieves the default plugin for the backend.
   *
   * @param $plugin_type
   *   The ctools plugin type of the plugin name to be retrieved.
   *
   * @return string
   *   The name of the default plugin to be used.
   */
  public function getDefaultPluginName($plugin_type) {
    // Do not provide default plugin names on the base backend.
    return FALSE;
  }

}
+8 −0
Changes for includes/VersioncontrolRepository.php: 8 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -519,7 +519,15 @@ abstract class VersioncontrolRepository implements VersioncontrolEntityInterface
      else {
        $variable = 'versioncontrol_repository_plugin_default_' . $plugin_slot;
      }
      // See if there is a default in the right variable.
      $plugin_name = variable_get($variable, '');
      if (empty($plugin_name)) {
        // Lets try to get a default value from the backend if any.
        $plugin_name = $this->getBackend()->getDefaultPluginName($plugin_type);
        if (empty($plugin_name)) {
          throw new Exception("A default plugin name could not be retrieved for plugin type '$plugin_type'.", E_WARNING);
        }
      }
    }
    else {
      $plugin_name = $this->plugins[$plugin_slot];