I'm a bit lost on how to create a custom entity. I need to go beyond the basics, but every example of Entity implementation I have seen has been different from one another and I am confused on the best way to go about this. I have read the docs included here, and in entity.inc, but wind up in circles.
I need to create an Entity that is like a node. It will store data, have a path, view modes, be used in Views, etc, and fieldable. Here is what I am using, gleamed from what I saw other modules doing:
Code:
$entities['isilink_property'] = array(
'label' => t('ISILink Property'),
'entity class' => 'ISILinkProperty',
'controller class' => 'ISILinkPropertyController',
'token type' => 'isilink_property',
'base table' => 'isilink_property',
'uri callback' => 'entity_class_uri',
'fieldable' => TRUE,
'view modes' => array(
'full' => array(
'label' => 'Full View',
'custom settings' => FALSE,
),
'search' => array(
'label' => 'Search View',
'custom settings' => TRUE,
),
'list' => array(
'label' => 'List View',
'custom settings' => TRUE,
),
),
'bundles' => array(
'isilink_property' => array(
'label' => t('ISILink Property'),
'admin' => array(
'path' => 'admin/structure/isilink/manage/isilink_property',
'real path' => 'admin/structure/isilink/manage/isilink-property',
'bundle argument' => 4,
),
),
),
'entity keys' => array(
'id' => 'id',
),
'admin ui' => array(
'path' => 'admin/content/isilink_property',
'file' => 'includes/isilink.property.admin.inc',
'controller class' => 'ISILinkPropertyUIController',
'menu wildcard' => '%isilink_property',
),
'module' => 'isilink',
'access callback' => 'isilink_property_entity_access',
);
As you can see above, I am trying to get the following:
- Define an Entity
- Provide Field management
- Provide a management UI for existing property Entities (like admin/content/node)
The first thing I cannot figure out is when I define the above in hook_entity_info(), drush rr inserts the menu paths above then removes the, (registry rebuild). Rebuilding the menu brings them back (checking menu_router table I can see them appear and disappear). Is this intentional, or is the definition wrong?
Second, when I visit admin/structure, I get two tabs now on the top for Manage Fields and Manage Display, pertaining to my entity. Why are these showing up and how can I get them to not do that? In fact what is a good way to do that to keep everything consistent (admin/(mymodule)/(myentity)/(whatever path))?
Comments
Comment #1
Anonymous (not verified) commentedI've found that this is a good tutorial to follow: http://www.trellon.com/content/blog/creating-own-entities-entity-api
Comment #2
kevinquillen commentedThanks- I can't believe its been 4 months already! I've got a much better handle on this now than then. I'm definitely bookmarking that for coworkers.
Comment #3
Anonymous (not verified) commentedComment #5
Rebekaloz commentedI can't make my entity fieldable, this is my code:
Eventhough I set the fieldable property to true and I have a single bundle defined.
I dont get the extra operations tabs.
Please the link that kevinquillen provided is broken.
Thank you!!