Skip to content
Thomas Weinert edited this page Aug 14, 2017 · 1 revision

Plugins should be implemented as Composer packages into thei own repositories. Please add the fluentdom/fluentdom as an dependency limited to the major version. The plugin APIs might (only) change between major version.

"require": {
  "fluentdom/fluentdom": "6.x",
  //...
},

Plugin Types

Loaders

Are used to load some content into a DOM document. They need to implement FluentDOM\Loadable and can be registered with FluentDOM::registerLoader().

Serializer Factories

Are functions or instances of FluentDOM\Serializer\Factory. Serializers need to implement __toString().

Xpath Transformers

The plugin convert an selector for the FluentDOM\Query object into Xpath expressions. At the moment here are two implementations that convert CSS selectors into Xpath expressions.

Registering Plugins

Plugins can be registered on the FluentDOM class. To register them automatically add an file autoloader to your composer.json.

"autoload": {
  "files" : ["src/plugin.php"],
  "psr-4": {
     //...
  }
}

Then use the static functions to register your plugins.

namespace FluentDOM\YourPlugin {
  \FluentDOM::registerLoader(
    new Loader(),
    'sometype',
    'someothertype'
  );
  \FluentDOM::registerSerializerFactory(
    function($contentType, \DOMNode $node) {
      return new Serializer($node);
    },
    'sometype',
    'someothertype'
  );
}
Clone this wiki locally