You are here

public static function PhotosAlbum::orderValue in Album Photos 6.0.x

Same name and namespace in other branches
  1. 8.5 src/PhotosAlbum.php \Drupal\photos\PhotosAlbum::orderValue()
  2. 8.4 src/PhotosAlbum.php \Drupal\photos\PhotosAlbum::orderValue()

Query helper: sort order and limit.

5 calls to PhotosAlbum::orderValue()
PhotosAlbum::getImages in src/PhotosAlbum.php
Get album images.
PhotosAlbum::nodeView in src/PhotosAlbum.php
Page and Teaser display settings.
PhotosAlbumController::albumView in src/Controller/PhotosAlbumController.php
Returns an overview of recent albums and photos.
PhotosAlbumTest::testOrderValue in tests/src/Unit/PhotosAlbumTest.php
@covers ::orderValue @dataProvider orderValueProvider
PhotosLegacyAlbumViewController::view in src/Controller/PhotosLegacyAlbumViewController.php
Returns the photos legacy album view.

File

src/PhotosAlbum.php, line 497

Class

PhotosAlbum
Create an album object.

Namespace

Drupal\photos

Code

public static function orderValue($field, $sort, $limit, $default = 0) {

  // @todo update default to check album default!
  $default_order = [
    'column' => 'p.id',
    'sort' => 'desc',
  ];
  if (!$field && !$sort) {
    $t['order'] = !$default ? $default_order : $default;
  }
  else {
    if (!($t['order'] = PhotosAlbum::orderValueChange($field, $sort))) {
      $t['order'] = !$default ? $default_order : $default;
    }
  }
  if ($limit) {
    $get_limit = \Drupal::request()->query
      ->get('limit');
    if ($get_limit && !($show = intval($get_limit))) {
      $get_destination = \Drupal::request()->query
        ->get('destination');
      if ($get_destination) {
        $str = $get_destination;
        if (preg_match('/.*limit=(\\d*).*/i', $str, $mat)) {
          $show = intval($mat[1]);
        }
      }
    }
    $t['limit'] = isset($show) ? $show : $limit;
  }
  return $t;
}