I want to make my entity fieldable and manageable from admin area with manage display and manage field admin ui. I have read few tutorials, but I still not understand how to do it? This question is related to my other question. Here is my entity code.
function statuses_entity_info() {
$backupControl = module_exists('entity') ? 'EntityAPIController' : 'DrupalDefaultEntityController';
return array(
'status' => array(
'label' => t('Status'),
'plural label' => t('Statuses'),
'description' => t('A status update.'),
'entity class' => 'StatusEntity',
'controller class' => module_exists('statuses') ? 'StatusesEntityController' : $backupControl,
'base table' => 'statuses',
'load hook' => 'statuses_load',
'uri callback' => 'statuses_uri',
'module' => 'statuses',
'entity keys' => array(
'id' => 'sid',
'label' => 'message',
),
'bundles' => array(
'status' => array(
'label' => t('Status'),
),
),
'view modes' => array(
'full' => array(
'label' => t('Status message'),
'custom settings' => FALSE,
),
),
'entity cache' => FALSE,
),
);
}
function statuses_entity_property_info() {
$info = array();
$info['status']['properties']['sid'] = array(
'label' => t('Status ID'),
'description' => t('The ID of the status'),
'type' => 'integer',
'schema field' => 'sid',
);
$info['status']['properties']['sender'] = array(
'label' => t('Status sender'),
'description' => t('Sender uid of the status message'),
'type' => 'integer',
'schema field' => 'sender',
);
$info['status']['properties']['recipient'] = array(
'label' => t('Status recipient'),
'description' => t('Recipient uid of the status message'),
'type' => 'integer',
'schema field' => 'recipient',
);
$info['status']['properties']['type'] = array(
'label' => t('Type'),
'description' => t('Type of status message'),
'type' => 'text',
'schema field' => 'type',
);
$info['status']['properties']['created'] = array(
'label' => t('Created'),
'description' => t('UNIX Timestamp of creation date'),
'type' => 'integer',
'schema field' => 'created',
);
$info['status']['properties']['message'] = array(
'label' => t('Message'),
'description' => t('Status message'),
'type' => 'text',
'schema field' => 'message',
);
return $info;
}
function statuses_uri($status) {
return array(
'path' => 'statuses/' . $status->sid,
);
}
class StatusesEntityController extends EntityAPIController {
//TODO
}
if (class_exists('Entity')) {
class StatusEntity extends Entity {
public function __construct(array $values = array(), $entityType = NULL) {
parent::__construct($values, 'status');
}
public function buildContent($view_mode = 'full', $langcode = NULL) {
$content['sender'] = array(
'#markup' => 'Sender Markup TEST',
);
$content['recipient'] = array(
'#markup' => 'Recipient Markup TEST',
);
$content['created'] = array(
'#markup' => 'Created Markup TEST',
);
$content['message'] = array(
'#markup' => 'Message Markup TEST',
);
$content['sid'] = array(
'#markup' => 'sid Markup TEST',
);
$content['type'] = array(
'#markup' => 'type Markup TEST',
);
return entity_get_controller($this->entityType)->buildContent($this, $view_mode, $langcode, $content);
}
}
}