function oauth2_server_entity_info in OAuth2 Server 7
Implements hook_entity_info().
File
- ./
oauth2_server.module, line 190 - Provides OAuth2 server functionality.
Code
function oauth2_server_entity_info() {
$items = array();
$items['oauth2_server'] = array(
'label' => t('OAuth2 Server'),
'controller class' => 'OAuth2ServerEntityController',
'entity class' => 'OAuth2Server',
'base table' => 'oauth2_server',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'server_id',
'label' => 'label',
'name' => 'name',
),
'exportable' => TRUE,
'export' => array(
'default hook' => 'default_oauth2_server',
),
'module' => 'oauth2_server',
'access callback' => 'oauth2_server_access',
'metadata controller class' => 'EntityDefaultMetadataController',
'views controller class' => 'EntityDefaultViewsController',
'admin ui' => array(
'path' => 'admin/structure/oauth2-servers',
'file' => 'includes/oauth2_server.server_admin.inc',
'controller class' => 'OAuth2ServerUIController',
),
);
$items['oauth2_server_scope'] = array(
'label' => t('OAuth2 Server - Scope'),
'controller class' => 'EntityAPIController',
'entity class' => 'OAuth2ServerScope',
'base table' => 'oauth2_server_scope',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'scope_id',
'label' => 'name',
'bundle' => 'server',
),
'module' => 'oauth2_server',
'access callback' => 'oauth2_server_scope_access',
'i18n controller class' => 'OAuth2ScopeI18nStringController',
'metadata controller class' => 'OAuth2ServerScopeMetadataController',
'views controller class' => 'EntityDefaultViewsController',
'admin ui' => array(
'path' => 'admin/structure/oauth2-servers/manage/%oauth2_server/scopes',
'file' => 'includes/oauth2_server.scope_admin.inc',
'controller class' => 'OAuth2ServerScopeUIController',
),
);
$items['oauth2_server_client'] = array(
'label' => t('OAuth2 Server - Client'),
'controller class' => 'EntityAPIController',
'entity class' => 'OAuth2ServerClient',
'base table' => 'oauth2_server_client',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'client_id',
'label' => 'label',
'bundle' => 'server',
),
'module' => 'oauth2_server',
'access callback' => 'oauth2_server_client_access',
'metadata controller class' => 'OAuth2ServerClientMetadataController',
'views controller class' => 'EntityDefaultViewsController',
'admin ui' => array(
'path' => 'admin/structure/oauth2-servers/manage/%oauth2_server_client/clients',
'file' => 'includes/oauth2_server.client_admin.inc',
'controller class' => 'OAuth2ServerClientUIController',
),
);
// The server serves as a bundle for scopes and clients.
// Bypass entity_load() as it cannot be used here (recursion).
// Check if oauth2_server exists first as it's possible for this hook to fire
// during the installation before the table has been created.
if (db_table_exists('oauth2_server')) {
$servers = db_select('oauth2_server', 'os')
->fields('os')
->execute()
->fetchAllAssoc('name');
foreach ($servers as $name => $server) {
$items['oauth2_server_scope']['bundles'][$name] = array(
'label' => $server->label,
);
$items['oauth2_server_client']['bundles'][$name] = array(
'label' => $server->label,
);
}
}
$items['oauth2_server_token'] = array(
'label' => t('OAuth2 Server - Token'),
'controller class' => 'OAuth2ServerTokenEntityController',
'entity class' => 'OAuth2ServerToken',
'base table' => 'oauth2_server_token',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'token_id',
'bundle' => 'type',
),
'bundles' => oauth2_server_token_bundles(),
'module' => 'oauth2_server',
'metadata controller class' => 'OAuth2ServerTokenMetadataController',
'views controller class' => 'EntityDefaultViewsController',
);
$items['oauth2_server_authorization_code'] = array(
'label' => t('OAuth2 Server - Authorization code'),
'controller class' => 'EntityAPIController',
'entity class' => 'OAuth2ServerAuthorizationCode',
'base table' => 'oauth2_server_authorization_code',
'fieldable' => TRUE,
'entity keys' => array(
'id' => 'code_id',
),
'module' => 'oauth2_server',
'metadata controller class' => 'OAuth2ServerAuthorizationCodeMetadataController',
// Authorization codes don't need Views integration.
'views controller class' => FALSE,
);
return $items;
}