Closed (fixed)
Project:
Ludwig
Version:
8.x-1.0
Component:
Code
Priority:
Normal
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
9 Oct 2017 at 10:07 UTC
Updated:
14 Feb 2021 at 01:24 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
devad commentedLinking to related issue from Swiftmailer module.
Comment #3
devad commentedSwiftmailer module is currently the only Drupal "HTML mail oriented" module which has significant D8 release (beta).
Drupal commerce needs such a module to send receipts to customers.
Bumping this issue to Major to inspire more community members to participate.
For all of us who are using Drupal Commerce + Ludwig this issue is definitely major.
Comment #4
mglamanOpen an issue and ask them to add a ludwig.json
Comment #5
mglamanRead the parent issue, sorry. Looks like we'd need to support
audoload.fileComment #6
devad commentedComment #7
mindaugasd commentedChanging title to my original one :)
For example, dompdf library autoload code (below), whatever this "classmap" really means - it looks like Ludwig at the moment does not support this neither.
Connecting this to related issue https://www.drupal.org/project/entity_print/issues/3040695
I temporary solved it by manually including additional classes with require_once and it started working.
Comment #8
hockey2112 commented@mindaugasd could you please provide a full explanation/code dump of how you got it to work? Thanks!
Comment #9
mindaugasd commented@hockey2112 In swiftmailer I added this line to the front of swiftmailer.module and swiftmailer.install.
and created ludwig.json file
In entity_print I added this line to entity_print.module
and created ludwig.json file.
Comment #10
hockey2112 commentedmindausasd,
Thanks for that explanation, extremely helpful!
I assume you placed the swiftmailer and html2txt library files in modules/swiftmailer/lib/... is that correct?
Comment #11
mindaugasd commentedYes, it is correct.
Comment #12
devad commentedHere is a new child issue which among other things is adding more support to PSR-4 and PSR-0 libraries: #3177450: Add warnings about unsupported autoload types and improve PSR types support
Comment #13
devad commentedA nice basis are established in #3177450: Add warnings about unsupported autoload types and improve PSR types support to support 'classmap' and 'files' autoload types as well.
If someone knows how to add to drupal container new classmap and/or files paths such help would be much appreciated.
Comment #14
devad commentedHere it is what composer is doing inside it's
composer/autoload_static.phpfile:Can we do something similar? Sorry I am not friendly with namespaces etc. :)
Comment #15
devad commentedWith #3177450: Add warnings about unsupported autoload types and improve PSR types support committed and new ver. 8.x-1.1 released today, all PSR-4 and PSR-0 libraries are supported in full now.
1. Previous problem with multiple-path libraries (such as
html2text/html2text) is solved by iterating through all paths and adding them as individual namespace records.2. Previous problem with multiple-resource libraries (such as
brightcove/apiandmaxmind/web-service-common) is solved as well by iterating through all resources and adding them as individual namespace records.3. All 'Classmap' and 'Files' libraries are giving proper warnings now that Ludwig is not supporting these autoload types yet.
Here are some of them:
Classmap autoload type
Files autoload type
Ludwig is not reporting these libraries as 'missing' any more (even after they are properly downloaded and unpacked). It is properly reporting them as installed but 'unsupported' now by adding a bold warning inside library's description.
Screenshot is attached with all said above visible inside the new Reports / Packages page.
@TODO
All "Classmap" and "Files" data are parsed properly now by
src/PackageManager.phpand are available tosrc/LudwigServiceProvider.php. We just need some coding expert to use these data properly and fill currently empty# @todo: Add Classmap and Files autoload types supportsection inside newsrc/LudwigServiceProvider.phpwith proper coding. If you know somebody... please ping him/her here. :)P.S. Renaming the title of this issue to reflect the remaining need.
Comment #16
devad commentedComment #17
devad commentedThe automatic support for 'classmap' and 'files' autoload types is not easy to implement due to the lack of such support inside Drupal and Symphony. Both Drupal and Symphony are relying fully on Composer in this regard.
One thing we can add is a Ludwig service which can be used as a helper service by contributed modules to manually require files needed by 'classmap' and 'files' autoload libraries.
Patch attached.
Please, see "Related issues" for new service usage examples.
Comment #19
devad commentedCommitted.
If somebody will figure out in the future how we can add support for 'classmap' and 'files' library types more directly - without the need from contrib modules to use new
ludwig.require_onceservice inside their .module and/or .install files - please feel free to reopen this issue or create a new one.Comment #20
devad commentedDigging the caller module directory name with debug_backtrace() might not have been the best idea.
I have noticed some issues with new Ludwig service when more than one contrib modules managed with Ludwig have dependencies on 'classmap' and/or 'files' library types.
1. So, let's make it simple and require the directory name from caller module as a third argument for our requireOnce() function.
2. And let's remove "Ludwig" from the beginning of the class name and method name and from the beginning of the file name - since it is not a best coding practice as suggested by @bojanz here.
3. And let's throw some exceptions if something is not structured well regarding ludwig.json file or service calls at caller module's side.
All together... quite a big patch.
Comment #22
devad commentedThrowing an exception if the file is not found is a bit extreme and can lead to problems with site availability.
Lets log an error here instead of throwing the exception.
Comment #24
devad commented