You are here

public static function PhotosAlbum::orderValue in Album Photos 8.4

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

Query helper: sort order and limit.

6 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
PhotosImagesRecentController::contentOverview in src/Controller/PhotosImagesRecentController.php
Returns content for recent images.

... See full list

File

src/PhotosAlbum.php, line 492

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!
  if (!$field && !$sort) {
    $t['order'] = !$default ? [
      'column' => 'f.fid',
      'sort' => 'desc',
    ] : $default;
  }
  else {
    if (!($t['order'] = PhotosAlbum::orderValueChange($field, $sort))) {
      $t['order'] = !$default ? [
        'column' => 'f.fid',
        'sort' => 'desc',
      ] : $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;
}