class Random

Same name in this branch
  1. 9 core/lib/Drupal/Component/Utility/Random.php \Drupal\Component\Utility\Random
Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/sort/Random.php \Drupal\views\Plugin\views\sort\Random
  2. 11.x core/tests/Drupal/TestTools/Random.php \Drupal\TestTools\Random
  3. 11.x core/lib/Drupal/Component/Utility/Random.php \Drupal\Component\Utility\Random

Handle a random sort.

Plugin annotation

@ViewsSort("random");

Hierarchy

Expanded class hierarchy of Random

6 string references to 'Random'
RotateImageEffect::submitConfigurationForm in core/modules/image/src/Plugin/ImageEffect/RotateImageEffect.php
SortRandomTest::getBasicRandomView in core/modules/views/tests/src/Kernel/Handler/SortRandomTest.php
Return a basic view with random ordering.
TaxonomyViewsFieldAccessTest::testTermFields in core/modules/taxonomy/tests/src/Kernel/Views/TaxonomyViewsFieldAccessTest.php
Check access for taxonomy fields.
views.sort.schema.yml in core/modules/views/config/schema/views.sort.schema.yml
core/modules/views/config/schema/views.sort.schema.yml
views_views_data in core/modules/views/views.views.inc
Implements hook_views_data().

... See full list

File

core/modules/views/src/Plugin/views/sort/Random.php, line 14

Namespace

Drupal\views\Plugin\views\sort
View source
class Random extends SortPluginBase implements CacheableDependencyInterface {
  use UncacheableDependencyTrait;
  
  /**
   * {@inheritdoc}
   */
  public function usesGroupBy() {
    return FALSE;
  }
  public function query() {
    $this->query
      ->addOrderBy('rand');
  }
  public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form, $form_state);
    $form['order']['#access'] = FALSE;
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.