LionsAd / service_container

Service Container Module on drupal.org - used for development and automated testing via travis

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Convert hook_libraries_info() to a file: [hook].libraries.yml

drupol opened this issue · comments

Let's discuss this. Now that service_container_symfony is taking care of .services.yml files, what about .libraries.yml files ?

This code allows use to use them:

function hook_libraries_info() {
  $libraries = array();

  foreach (module_list() as $module) {
    $filename = drupal_get_filename('module', $module);
    $libraries_file = dirname($filename) . "/$module.libraries.yml";
    if (file_exists($libraries_file)) {
      $new_libraries = \Drupal\Component\Serialization\Yaml::decode(file_get_contents($libraries_file));
      $libraries = array_merge($libraries, $new_libraries);
    }
  }

  return $libraries;
}

Certainly not a bad idea but I'm curious whether this is part of the scope of the module.
Do we want to provide Drupal 8 API in Drupal 7, or do we "just" want to provide a server_container + services?

Note: The syntax of .library.info is a bit different than hook_libraries_info() ... for example the libraries are represented like system/example

I am for Drupal 8 API in Drupal 7, but if we add such functionality it should be in a submodule, e.g. service_container_libraries.

On the other hand its true that this has nothing to do with the service_container per se. (while e.g. supporting plugins in Drupal 7 with annotations would be in scope still as its much related to the service_container).

Lets create a new module and call it drupal8_bridge?

On the other hand, I hate it when I need to download 100 modules that do different things (e.g. ds), I am a huge fan of monolithic modules with submodules.

So, let's do a service_container_libraries ?

Yes. Lets start with that, but we will need to write an adapter from D8 services.yml syntax to hook_library() and hook_libraries_info().

Proposed module structure:

service_container
|-modules
| |-service_container_symfony
| | |-modules
| | | |-service_container_libraries

uhm, no :)

service_container
  modules
    bridge
      service_container_symfony
      service_container_libraries