You are here

class OAuth2ServerUIController in OAuth2 Server 7

UI controller.

Hierarchy

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);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
EntityDefaultUIController::$entityInfo protected property
EntityDefaultUIController::$entityType protected property
EntityDefaultUIController::$id_count protected property
EntityDefaultUIController::$overviewPagerLimit public property Defines the number of entries to show per page in overview table.
EntityDefaultUIController::applyOperation public function Applies an operation to the given entity.
EntityDefaultUIController::entityFormSubmitBuildEntity public function Entity submit builder invoked via entity_ui_form_submit_build_entity().
EntityDefaultUIController::hook_forms public function Provides definitions for implementing hook_forms().
EntityDefaultUIController::operationCount protected function Returns the operation count for calculating colspans.
EntityDefaultUIController::operationFormSubmit public function Operation form submit callback. 1
EntityDefaultUIController::operationFormValidate public function Operation form validation callback.
EntityDefaultUIController::overviewForm public function Builds the entity overview form.
EntityDefaultUIController::overviewFormSubmit public function Overview form submit callback.
EntityDefaultUIController::overviewFormValidate public function Overview form validation callback.
EntityDefaultUIController::overviewTable public function Generates the render array for a overview table for arbitrary entities matching the given conditions.
EntityDefaultUIController::__construct public function
OAuth2ServerUIController::hook_menu public function Overrides hook_menu() defaults. Overrides EntityDefaultUIController::hook_menu
OAuth2ServerUIController::operationForm public function Overrides EntityDefaultUIController::operationForm(). Overrides EntityDefaultUIController::operationForm
OAuth2ServerUIController::overviewTableHeaders protected function Overrides EntityDefaultUIController::overviewTableHeaders(). Overrides EntityDefaultUIController::overviewTableHeaders
OAuth2ServerUIController::overviewTableRow protected function Overrides EntityDefaultUIController::overviewTableRow(). Overrides EntityDefaultUIController::overviewTableRow