You are here

class OAuth2ServerClientUIController in OAuth2 Server 7

UI controller.

Hierarchy

Expanded class hierarchy of OAuth2ServerClientUIController

1 string reference to 'OAuth2ServerClientUIController'
oauth2_server_entity_info in ./oauth2_server.module
Implements hook_entity_info().

File

includes/oauth2_server.client_admin.inc, line 10
Admin UI for clients.

View source
class OAuth2ServerClientUIController extends EntityDefaultUIController {
  public function __construct($entity_type, $entity_info) {
    $this->statusKey = 'status';
    $this->entityType = $entity_type;
    $this->entityInfo = $entity_info;

    // Stop the UI from mentioning "OAuth2 client" everywhere.
    $this->entityInfo['label'] = 'Client';

    // Replace the client placeholder with the server name, since the path
    // is used for links and redirects.
    $this->path = str_replace('%oauth2_server_client', arg(4), $this->entityInfo['admin ui']['path']);
  }

  /**
   * Overrides EntityDefaultUIController::hook_menu().
   */
  public function hook_menu() {
    $items = array();
    $path = 'admin/structure/oauth2-servers/manage/%/clients';
    $id_pos = count(explode('/', $path));
    $items[$path] = array(
      'title' => 'Clients',
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'oauth2_server_client_overview_form',
        'oauth2_server_client',
      ),
      'description' => 'Manage clients.',
      'access callback' => 'entity_access',
      'access arguments' => array(
        'view',
        'oauth2_server_client',
      ),
      'type' => MENU_LOCAL_TASK,
      'file' => 'includes/entity.ui.inc',
      'weight' => 10,
    );
    $items[$path . '/add'] = array(
      'title' => 'Add client',
      'page callback' => 'entity_ui_get_bundle_add_form',
      'page arguments' => array(
        'oauth2_server_client',
        4,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'create',
        'oauth2_server_client',
      ),
      'type' => MENU_LOCAL_ACTION,
      'file' => $this->entityInfo['admin ui']['file'],
      'file path' => drupal_get_path('module', 'oauth2_server'),
    );

    // The regular Entity API way would be to use
    // $path . '/manage/%entity_object' here, but Drupal's Menu API is limited
    // to 9 levels, one too little for that to work.
    $items[$path . '/%entity_object'] = array(
      'title' => 'Edit',
      'title callback' => 'entity_label',
      'title arguments' => array(
        'oauth2_server_client',
        $id_pos,
      ),
      'page callback' => 'entity_ui_get_form',
      'page arguments' => array(
        'oauth2_server_client',
        $id_pos,
      ),
      'load arguments' => array(
        'oauth2_server_client',
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'update',
        'oauth2_server_client',
        $id_pos,
      ),
      'file' => $this->entityInfo['admin ui']['file'],
      'file path' => drupal_get_path('module', 'oauth2_server'),
    );
    $items[$path . '/%entity_object/edit'] = array(
      'title' => 'Edit',
      'load arguments' => array(
        'oauth2_server_client',
      ),
      'type' => MENU_DEFAULT_LOCAL_TASK,
    );
    $items[$path . '/%entity_object/delete'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        'oauth2_server_client_operation_form',
        'oauth2_server_client',
        $id_pos,
        'delete',
      ),
      'load arguments' => array(
        'oauth2_server_client',
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'delete',
        'oauth2_server_client',
        $id_pos,
      ),
      'file' => 'includes/entity.ui.inc',
    );
    return $items;
  }

  /**
   * Overrides EntityDefaultUIController::overviewTable().
   */
  public function overviewTable($conditions = array()) {
    $conditions['server'] = arg(4);
    return parent::overviewTable($conditions);
  }

  /**
   * Overrides EntityDefaultUIController::overviewTableRow().
   */
  protected function overviewTableRow($conditions, $id, $entity, $additional_cols = array()) {
    $entity_uri = entity_uri($this->entityType, $entity);
    $row[] = array(
      'data' => array(
        '#theme' => 'entity_ui_overview_item',
        '#label' => entity_label($this->entityType, $entity),
        '#name' => FALSE,
        '#url' => $entity_uri ? $entity_uri : FALSE,
        '#entity_type' => $this->entityType,
      ),
    );

    // Add in any passed additional cols.
    foreach ($additional_cols as $col) {
      $row[] = $col;
    }

    // Add the edit and delete links.
    $row[] = l(t('edit'), $this->path . '/' . $id);
    $row[] = l(t('delete'), $this->path . '/' . $id . '/delete', array(
      'query' => drupal_get_destination(),
    ));
    return $row;
  }

}

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::operationForm public function Builds the operation form.
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::overviewTableHeaders protected function Generates the table headers for the overview table.
OAuth2ServerClientUIController::hook_menu public function Overrides EntityDefaultUIController::hook_menu(). Overrides EntityDefaultUIController::hook_menu
OAuth2ServerClientUIController::overviewTable public function Overrides EntityDefaultUIController::overviewTable(). Overrides EntityDefaultUIController::overviewTable
OAuth2ServerClientUIController::overviewTableRow protected function Overrides EntityDefaultUIController::overviewTableRow(). Overrides EntityDefaultUIController::overviewTableRow
OAuth2ServerClientUIController::__construct public function Overrides EntityDefaultUIController::__construct