jpamental / typogrify

Drupal 8 port of the Typogrify module
GNU General Public License v2.0
3 stars 4 forks source link

Convert include statements to autoloading classes. #7

Closed benjifisher closed 8 years ago

benjifisher commented 8 years ago

There are several places where the module uses Drupal's module_load_include() to include a file that defines a class. For example, in src/Plugin/Filter/TypogrifyFilter.php:

    module_load_include('class.php', 'typogrify');
    module_load_include('php', 'typogrify', 'unicode-conversion');
    module_load_include('php', 'typogrify', 'smartypants');

The first line includes a class; the others define functions in the global namespace.

First, we should check if these are available as external libraries. If so, then their code should be included using composer and they should be autoloaded.

If they are not available as external libraries, then we should get them inside the src/ directory, put the functions inside a class, and access then through the autoloader.

In fact, this second option is half-done, at least for the file typogrify.class.php. Basically, a copy was added as src/Typogrify.php and then that version was cleaned up in PR #5. I think that the copy under src/ is unused.

Note that module_load_include() is used in the test files as well.