It would be great if either modules could add library paths, or modify existing ones, or if libraries could exist within subdirectories of existing library paths (for organization and deployment purposes).

an example situation:
a project has libraries externally created and internally created and needs them organized w/in the sites/all/libraries construct similar to how modules and themes can be organized w/in their respective directory structures. presently, putting a library into sites/all/libraries/contrib would cause the library to be ignored when searched for.

for now, my proposed solution addresses "adding library paths" which indirectly solves the other two items to some degree. In libraries_get_libraries, there should at a minimum be a drupal_alter("libraries_directories", $searchdir); that allows the paths to be appended to, or modified.

by providing an alter() hook, projects can at least put in a custom specific path that will allow libraries to reach their specific paths. example:

function my_project_libraries_directories_alter(&$paths){
  $paths[]="sites/all/libraries/contrib";
  $paths[]="sites/all/libraries/custom";
}
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

netw3rker’s picture

arnested’s picture

Status: Active » Reviewed & tested by the community
FileSize
1.11 KB

I have the same need.

My use case is having an installation profile inheriting another installation profile with the help from profiler. I need to specify the libraries folder of the base installation profile.

I fixed code style issues in the patch (formatting the comment) and added documentation of the alter hook in libraries.api.php.

tstoeckler’s picture

Status: Reviewed & tested by the community » Needs work

To be honest I consider this a little bit of a can of worms. The example in the issue summary, for example, will break on libraries called contrib or custom. Note that library discovery is very much different than e.g. module discovery for which this is not a problem. You could solve that problem by removing sites/all/libraries from the list of paths. But then it's also weird to have the contrib/custom thing in sites/all, but not in sites/default, etc. So I'm not sure this is a good idea, TBH, at least not as a hook.

I can see how this could be useful on a custom site, but using an alter hook also allows contrib modules or others to employ this, which I don't think I'm comfortable with.

What about providing a hidden variable that can be set from settings.php? I would have no problem with something like that.