class OAuth2ServerUIController in OAuth2 Server 7
UI controller.
Hierarchy
- class \EntityDefaultUIController
- class \OAuth2ServerUIController
Expanded class hierarchy of OAuth2ServerUIController
1 string reference to 'OAuth2ServerUIController'
- oauth2_server_entity_info in ./
oauth2_server.module - Implements hook_entity_info().
File
- includes/
oauth2_server.server_admin.inc, line 10 - Admin UI for servers.
View source
class OAuth2ServerUIController extends EntityDefaultUIController {
/**
* Overrides hook_menu() defaults.
*/
public function hook_menu() {
$items = parent::hook_menu();
$items[$this->path]['description'] = 'Manage servers and their associated clients and scopes.';
// Fix the "Add oauth2 server" and "Import oauth2 server" titles.
unset($items[$this->path . '/add']['title callback']);
unset($items[$this->path . '/add']['title arguments']);
unset($items[$this->path . '/import']['title callback']);
unset($items[$this->path . '/import']['title arguments']);
$items[$this->path . '/add']['title'] = 'Add server';
$items[$this->path . '/import']['title'] = 'Import server';
return $items;
}
/**
* Overrides EntityDefaultUIController::overviewTableHeaders().
*/
protected function overviewTableHeaders($conditions, $rows, $additional_header = array()) {
$additional_header[] = t('Clients');
$additional_header[] = t('Scopes');
return parent::overviewTableHeaders($conditions, $rows, $additional_header);
}
/**
* Overrides EntityDefaultUIController::overviewTableRow().
*/
protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
$additional_cols[] = l(t('clients'), $this->path . '/manage/' . $id . '/clients');
$additional_cols[] = l(t('scopes'), $this->path . '/manage/' . $id . '/scopes');
return parent::overviewTableRow($conditions, $id, $entity, $additional_cols);
}
/**
* Overrides EntityDefaultUIController::operationForm().
*/
public function operationForm($form, &$form_state, $entity, $op) {
if ($op == 'delete') {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'oauth2_server_scope');
$query
->propertyCondition('server', $entity->name);
$query
->count();
$num_scopes = $query
->execute();
$num_clients = 0;
// If there's at least one scope, we know the delete can't proceed,
// so no need to count clients.
if ($num_scopes == 0) {
$query = new EntityFieldQuery();
$query
->entityCondition('entity_type', 'oauth2_server_client');
$query
->propertyCondition('server', $entity->name);
$query
->count();
$num_clients = $query
->execute();
}
if ($num_scopes > 0 || $num_clients > 0) {
drupal_set_message(t('This server has associated scopes and/or clients, it cannot be deleted.'), 'error');
return array();
}
}
return parent::operationForm($form, $form_state, $entity, $op);
}
}