note: I'm currently exploring hook_entity_property_info_alter and clearing the cache forcibly by truncating the cache table as I've had many iterations of work on this over the years. (Though I wouldn't recommend you trying that and if you do, back up first!)
I've defined entities in
hook_entity_info. But when I have I get differing results and none of them work in Views as I was hoping.
"Paid subs" doesn't give me control of individual fields and therefore allow me to mix one field here with another of a joined entity there. But it does give fairly decent information.
This is its definition in
$info['paid_sub'] = array( 'label' => t('Paid subscription'), 'plural label' => t('Paid subscriptions'), 'description' => t('company paid subscriptions (in theory this could be just postage or the full cover price etc.'), 'base table' => 'company_paid_subs', 'entity keys' => array( 'id' => 'psid', ), 'uri callback' => 'entity_class_uri', 'entity class' => 'PaidSubEntity', 'controller class' => 'PaidSubEntityController', 'admin ui' => array( 'path' => 'admin/paid-subs', 'controller class' => 'PaidSubEntityUIController', 'menu wildcard' => '%paidsubentity', 'file' => 'paidsubentity.admin.inc', ), 'module' => 'company_subs', 'access callback' => 'paidsubentity_access_callback', 'label callback' => 'paidsubentity_label_callback', 'views controller class' => 'EntityDefaultViewsController', );
This one: "Subscription" doesn't do anything remotely useful.
$info['subscription'] = array( 'label' => t('Subscription'), 'plural label' => t('Subscriptions'), 'description' => t('A subscription (as opposed to user registrations, paid recipients of magazines, promo readers etc.)'), 'base table' => 'subscription', 'entity keys' => array( 'id' => 'sid', 'revision' => 'revision_id', ), 'entity class' => 'SubscriptionEntity', 'controller class' => 'SubscriptionEntityController', 'module' => 'company_subs', 'access callback' => 'subscriptionentity_access_callback', 'label callback' => 'susbcriptionentity_label_callback', 'revision table' => 'subscription_revision', );
Is it because I have been overriding default configurations? What's the cause? Ideally I'd like to be able to select individual fields within an entity rather than having to rely on a rendered entity because I'd like to be able to select one field from one entity and another from another entity by using joins in
hook_views_data_alter, like this (which worked just fine until I stopped defining each field in
hook_views_data and turned the bespoke tables into entities specifically to try and utilise the extra functionality of core and contrib modules etc.):
$data['subscription']['user_id'] ['relationship']['handler'] = 'views_handler_relationship'; $data['subscription']['user_id'] ['relationship']['base'] = 'users'; $data['subscription']['user_id'] ['relationship']['base field'] = 'uid';