This project is read-only.

Difference between adding part to a type with migrations or ActivatingFilter

Topics: General, Writing modules
Nov 14, 2011 at 2:06 PM

I've seen two approaches when one'd like to create or alter a content type by attaching a part to it: either do this in the migrations or with ActivatingFilter in the handler. It seem that the latter only creates an on-the-fly connection (I don't know one could really take this as the same as attaching, since I guess adding an ActivatingFilter only makes it look that there is a content type, but really there isn't) while the former alters the content type permanently (and this one is only saved to the DB).

I've seen an interesting mix where the Users module creates the User content type in the handler while the Contrib.Profile module makes an alteration to the type in the migrations (although at the time of the migration running there is most likely no User type definition saved, so it creates it).

Are there any best practices regarding these techniques? I guess migrations is the way to go if we want the users to be able to alter the type too, from the admin page (because as I see handler activations don't show up there).

Nov 15, 2011 at 1:53 AM

Yes. There are two reasons to do it from the handler: old code that predates the metadata API, or adding parts per instance based on some condition. In all other cases, migrations are the way to go.

Nov 15, 2011 at 8:21 PM

Thanks for the clarification!