sheadawson / silverstripe-shortcodable

Provides a GUI for CMS users to insert Shortcodes into the HTMLEditorField + an API for developers to define Shortcodable DataObjects and Views.
MIT License
48 stars 36 forks source link

Unable to register classes with extensions #39

Closed sekjal closed 8 years ago

sekjal commented 8 years ago

ShortcodeParser->register() checks to see if the supplied method is_callable. However, if the classname is provided as a string instead of an instance, extensions will not be applied. Setting the object param as a singleton of the class solves this problem.

To test:

  1. Create and apply an extension to Member with parse_shortcode() implemented (can just return a string, no need for a template)
  2. Add Member as a shortcodable_class to Shortcodable in config.yml
  3. flush
  4. Attempt to insert the shortcode in a page. The code will be inserted properly, but remain unparsed and ugly.
sheadawson commented 8 years ago

Thanks for this, your PR was almost right, see #91561b7