getSort example


  public function tableSort(&$headers) {
    // If 'field' is not initialized, the header columns aren't clickable.     foreach ($headers as $key => $header) {
      if (is_array($header) && isset($header['specifier'])) {
        $headers[$key]['field'] = '';
      }
    }

    $order = TableSort::getOrder($headers, \Drupal::request());
    $direction = TableSort::getSort($headers, \Drupal::request());
    foreach ($headers as $header) {
      if (is_array($header) && ($header['data'] == $order['name'])) {
        $this->sort($header['specifier']$direction$header['langcode'] ?? NULL);
      }
    }

    return $this;
  }

  /** * Makes sure that the Condition object is cloned as well. */

  public static function getContextFromRequest(array $headers, Request $request) {
    $context = static::getOrder($headers$request);
    $context['sort'] = static::getSort($headers$request);
    $context['query'] = static::getQueryParameters($request);
    return $context;
  }

  /** * Formats a column header. * * If the cell in question is the column header for the current sort * criterion, it gets special formatting. All possible sort criteria become * links. * * @param string $cell_content * The cell content to format. Passed by reference. * @param array $cell_attributes * The cell attributes. Passed by reference. * @param array $header * An array of column headers in the format described in '#type' => 'table'. * @param array $context * The current table sort context as returned from * TableSort::getContextFromRequest() method. * * @throws \Exception * * @see getContextFromRequest() */
Home | Imprint | This part of the site doesn't use cookies.