Convert D7 input filter into D8 plugin for Graph API
Submitted by clemens on Wed, 2014/01/01 - 10:24am
For Graph API the Trivial Graph Format submodule introduced into 7.x-1.x needed an upgrade to Drupal 8 lingo. My initial thought was to upgrade the sub module to discover hook_filter_info was gone.
Checking the filter.api.php there is more gone then kept.
Once you know it's a plugin it is almost trivial apart from the annotated part.
Being a plugin means you are building a class which resides into sites/all/graphapi/lib/Drupal/graphapi/ directory tree somewhere. (Note this is PSR-0 tree and probably will change into PSR-4 tree. See PSR-4: Putting it all together)
Thanks to almaudoh's remark I learned we have an enforced directory tree.
Plugins belong to the Plugin and filter plugins in the Filter so the full path is now lib/Drupal/graphapi/Plugin/Filter.
FILTER_TYPE_MARKUP_LANGUAGE: The filter converts something that's not HTML to HTML in a way that is not compatible with WYSIWYG editing.
FILTER_TYPE_HTML_RESTRICTOR: The filter restricts the HTML allowed, for example, to protect against XSS.
FILTER_TYPE_TRANSFORM_REVERSIBLE: The filter performs a transform for which a WYSIWYG plugin exists to perform the same transformation (and its reverse) client-side. For example, may be (reversibly!) transformed to Druplicon.
FILTER_TYPE_TRANSFORM_IRREVERSIBLE: The filter performs a transform for which a WYSIWYG plugin does not exist to perform the transformation client-side (especially, the reverse of it); instead, the WYSIWYG editor displays the unfiltered text. For example, Token Filter.
Trivial Graph Format (extended version)
The image above is generated by the following filter input