You are here

class TMGMTLocalTaskUIController in Translation Management Tool 7

Entity UI controller for the local task entity.

Hierarchy

Expanded class hierarchy of TMGMTLocalTaskUIController

1 string reference to 'TMGMTLocalTaskUIController'
tmgmt_local_entity_info in translators/tmgmt_local/tmgmt_local.module
Implements hook_entity_info().

File

translators/tmgmt_local/controller/tmgmt_local.ui_controller.task.inc, line 6

View source
class TMGMTLocalTaskUIController extends EntityDefaultUIController {

  /**
   * {@inheritdoc}
   */
  public function hook_menu() {
    $id_count = count(explode('/', $this->path));
    $wildcard = isset($this->entityInfo['admin ui']['menu wildcard']) ? $this->entityInfo['admin ui']['menu wildcard'] : '%entity_object';
    $items[$this->path . '/' . $wildcard] = array(
      'title callback' => 'entity_label',
      'title arguments' => array(
        $this->entityType,
        $id_count,
      ),
      'page callback' => 'tmgmt_local_task_view',
      'page arguments' => array(
        $id_count,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'view',
        $this->entityType,
        $id_count,
      ),
      'file' => 'tmgmt_local.pages.inc',
      'file path' => drupal_get_path('module', 'tmgmt_local') . '/includes',
    );
    $items[$this->path . '/' . $wildcard . '/delete'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        $this->entityType . '_operation_form',
        $this->entityType,
        $id_count,
        $id_count + 1,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'delete',
        $this->entityType,
        $id_count,
      ),
      'type' => MENU_CALLBACK,
    );
    $items[$this->path . '/' . $wildcard . '/unassign'] = array(
      'page callback' => 'drupal_get_form',
      'page arguments' => array(
        $this->entityType . '_operation_form',
        $this->entityType,
        $id_count,
        $id_count + 1,
      ),
      'load arguments' => array(
        $this->entityType,
      ),
      'access callback' => 'entity_access',
      'access arguments' => array(
        'unassign',
        $this->entityType,
        $id_count,
      ),
      'type' => MENU_CALLBACK,
    );
    return $items;
  }

  /**
   * {@inheritdoc}
   */
  public function operationForm($form, &$form_state, $entity, $op) {
    switch ($op) {
      case 'delete':
        $confirm_question = t('Are you sure you want to delete the translation task %label?', array(
          '%label' => $entity
            ->label(),
        ));
        return confirm_form($form, $confirm_question, $this->path);
      case 'unassign':
        $confirm_question = t('Are you sure you want to unassign from the translation task %label?', array(
          '%label' => $entity
            ->label(),
        ));
        return confirm_form($form, $confirm_question, $this->path);
    }
    drupal_not_found();
    exit;
  }

  /**
   * {@inheritdoc}
   */
  public function applyOperation($op, $entity) {
    switch ($op) {
      case 'delete':
        $entity
          ->delete();
        return t('Deleted the translation local task %label.', array(
          '%label' => $entity
            ->label(),
        ));
      case 'unassign':
        $entity
          ->unassign();
        $entity
          ->save();
        return t('Unassigned from translation local task %label.', array(
          '%label' => $entity
            ->label(),
        ));
    }
    return FALSE;
  }

}

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::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::overviewTableHeaders protected function Generates the table headers for the overview table.
EntityDefaultUIController::overviewTableRow protected function Generates the row for the passed entity and may be overridden in order to customize the rows.
EntityDefaultUIController::__construct public function
TMGMTLocalTaskUIController::applyOperation public function Applies an operation to the given entity. Overrides EntityDefaultUIController::applyOperation
TMGMTLocalTaskUIController::hook_menu public function Provides definitions for implementing hook_menu(). Overrides EntityDefaultUIController::hook_menu
TMGMTLocalTaskUIController::operationForm public function Builds the operation form. Overrides EntityDefaultUIController::operationForm