Article updated August 2013 and again in March 2014 to reflect the latest core D8 changes. Complete module example (see attachment) is also up-to-date.
"I woke up this morning and all my shrimps was dead and gone. Someone's been fishing in my pond…" -- Robert Johnson
A few days ago I woke up to the latest version of D8 core, only to find that "everything" in my freshly ported fully operational D8 module was broken. While getting to the root course, I couldn't help grumbling the above words by the late great bluesman in his wonderful Dead Shrimp Blues. Replace "shrimps" by "hooks" and think of that "someone" as the D8 core team and you have a wonderful analogy.
One by one the hard-working core team are killing off our trusted hooks, replacing them by equivalent Symfony classes and their magic annotations. Your implementations won't be called any more. Say sayonara to your hooks.
It's all for the greater good, of course.
But initially the mind boggled.
To get a grip and make my module work again, I went back to basics. I wrote a minimum code base to programmatically create a field with associated widget and formatter. It has become my "field+widget+formatter starter pack" when implementing fields in D8.
The commented code is attached as a fully functional module and we posted it to drupal.org, as well.
All the field, widget and formatter hooks have been retired. Here's what you'll have to add to re-instate the D7 functionality provided by your field type, widget and formatter hook implementations.
In the /modules directory you need to create the following files, each holding a class and its essential annotations.
Tips to avoid the Dead Hook Blues:
o Don't have superfluous trailing comma's in your annotations -- the effect is calamitous.
o In your field_type class, implement
isEmpty() correctly or you may find that submitted form values don't save!
o Once you've mastered the starter pack, have a look at the source of core's Telephone and Link modules for a step up in complexity and in becoming a D8 pro!