Declaring our entity
There are two parts to telling Drupal about our new entity. The first is another definition hook called
hook_entity_info(). This hook tells Drupal about the entity or entities we're providing, and also provides the Field UI system with the information it needs to allow us to attach fields to entities—more on that later. The second part is a "controller class", which is a PHP class that will be responsible for loading and, in our case, creating, saving, and deleting our artwork.
Drupal includes a controller class called
DrupalDefaultEntityController that handles the most common case, which we will be emulating. It is extremely basic, however, and only handles loading of objects. Fortunately it is very easy to subclass the default ...