nerds-and-company / schematic

Craft Setup Sync
MIT License
136 stars 15 forks source link

Added ability to inject custom converters with an event #132

Closed bvangennep closed 6 years ago

bvangennep commented 6 years ago

Custom converters can be injected with the EVENT_RESOLVE_CONVERTER event. This can be especially useful for importing and exporting custom field types. The converters need to implement the NerdsAndCompany\Schematic\Interfaces\ConverterInterface.

Event::on(Schematic::class, Schematic::EVENT_RESOLVE_CONVERTER, function (ConverterEvent $event) {
    if ($event->modelClass = "My\Custom\Field") {
      $event->converterClass = "My\Custom\FieldConverter";
    }
});

Fixes #123