public function OAuth2ServerEntityController::export in OAuth2 Server 7
Overrides EntityAPIControllerExportable::export().
Overrides EntityAPIControllerExportable::export
File
- includes/
oauth2_server.server_controller.inc, line 44
Class
- OAuth2ServerEntityController
- The entity controller for oauth2_server entities.
Code
public function export($entity, $prefix = '') {
$vars = get_object_vars($entity);
unset($vars['server_id'], $vars['status'], $vars['module'], $vars['is_new']);
$vars['scopes'] = array();
// Get a list of all scopes belonging to this server.
// Add the "oauth2_server_scope_export" tag so that other modules can
// restrict which scopes should be exported.
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'oauth2_server_scope');
$query
->propertyCondition('server', $entity->name);
$query
->addTag('oauth2_server_scope_export');
$query
->addMetaData('oauth2_server', $entity);
$results = $query
->execute();
if ($results) {
$scope_ids = array_keys($results['oauth2_server_scope']);
$scopes = entity_load('oauth2_server_scope', $scope_ids);
foreach ($scopes as $scope) {
$scope_vars = get_object_vars($scope);
unset($scope_vars['scope_id'], $scope_vars['server']);
$vars['scopes'][] = $scope_vars;
}
}
return entity_var_json_export($vars, $prefix);
}