Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding a custom field handler #399

Open
jludwig opened this issue Aug 1, 2017 · 3 comments
Open

Adding a custom field handler #399

jludwig opened this issue Aug 1, 2017 · 3 comments

Comments

@jludwig
Copy link

jludwig commented Aug 1, 2017

From what I can tell in \Drupal\Driver\Cores\AbstractCore::getFieldHandler(), the only way to add a custom field handler is to put it in the \Drupal\Driver\Fields{core} namespace.

We are using a Composer-based build process, so when we require custom field handlers, I'm just adding patches to drupalextension to place a new field handler into the proper directory.

Is there another way to do this currently? If not, should there be? It seems like something a custom module that defines a custom field should be able to add.

@jonathanjfshaw
Copy link
Contributor

I think we need a proper plugin system for field handlers, not the half-baked home-baked plugins we currently use.

My idea is use D8's core-plugins component as a composer dependency and build Field and Entity plugin systems using that. Would be sweet.

@johnhelmuth
Copy link

Has there been any more work done on implementing a plugin system to extend the field handlers allowed? We are looking at supporting the GeofieldItem field type from the Geofield module, and would like to keep it mostly forward compatible.

To get the handler class loaded in a composer managed codebase, with the current implementation of getFieldHandler(), I think you could autoload it in the composer.json autoload-dev key, with the full PHP class namespace \Drupal\Driver\Cores\Fields\Drupal8\ (for example) specified alongside the path to your class.

I haven't tried this yet, but it seems like it should work.

@jonathanjfshaw
Copy link
Contributor

See jhedstrom/DrupalDriver#157

I figure we're 80% of the way there. Reviews and help very much appreciated.

It works fine already for D8, and you could use it as a patch, but not in a way that would give you perfect stable forward compatibility. If your needs are complex (multiple inter-related entities, interventions at different points in entity lifecycle), it might be worth it. If they are simple (e.g. just one field) and you don't want to have to make adjustments down the road, then it's not for you right now.

I think I've seen someone make a custom field handler work by slipping the class into their FeatureContext file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants