It's been suggested to me that MB be split into the core part and the UI. This has a lot of benefits:

- the core remains Drupal core version-independent, like drush, while the UI module can clearly have core compatibility
- the core can be used with different Drupal core versions. (At the moment, to ensure that, I'd have to keep the D6 branch 'MB core' files in sync with the branch I'm working on.)
- different UIs can be developed for different tasks. (For example, a theme builder, or #2046903: 'functionality' based components.)
- the UI modules can have stable releases
- the UI for MB will get some much-needed love!

I think the best way to handle this would be to make MB core something that can be used in one of two ways:

- as a drush plugin (which it currently is)
- as a library which can go in a site's sites/all/libraries folder

MB UI modules would then need a dependency on Libraries module to load it.

Next steps to implement this would be:

- try running MB core as a library! (I'm tinkering with this now)
- make any code changes so it's easy for UI modules to get the API functions they need
- clearly define which functions are the public API and therefore won't change without warning (!!)
- remove the current UI module code from MB core

Comments

joachim’s picture

This works:

/**
 * Implements hook_libraries_info().
 */
function module_builder_ui_libraries_info() {
  // The following is a full explanation of all properties. See below for more
  // concrete example implementations.

  // This array key lets Libraries API search for 'sites/all/libraries/example'
  // directory, which should contain the entire, original extracted library.
  $libraries['module_builder'] = array(
    // Only used in administrative UI of Libraries API.
    'name' => 'Module Builder Core',
    'vendor url' => 'http://example.com',
    'download url' => 'http://example.com/download',
    // We have to declare a version.
    'version' => 'none',
    // Default list of files of the library to load. Important: Only specify
    // third-party files belonging to the library here, not integration files of
    // your module.
    'files' => array(
      // For PHP libraries, specify include files here, still relative to the
      // library path.
      'php' => array(
        'includes/common.inc',
      ),
    ),
    // Optional: Register files to auto-load for your module. All files must be
    // keyed by module, and follow the syntax of the 'files' property.
    'integration files' => array(
      'module_builder_ui' => array(
        'php' => array('includes/common.inc'),
      ),
    ),
  );

  return $libraries;
}

Using the library is a different matter though... mostly because MB core can't get to its hook data folder.

Subtask split off to #2046925: use dependency injection to provide MB core with environment settings.

joachim’s picture

Status: Active » Fixed

The current UI module is probably going to stick around for a while, just as an example.

Meanwhile, there's going to be a new Module Builder UI project.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.