You are here

class Random in Drupal 10

Same name in this branch
  1. 10 core/lib/Drupal/Component/Utility/Random.php \Drupal\Component\Utility\Random
  2. 10 core/modules/views/src/Plugin/views/sort/Random.php \Drupal\views\Plugin\views\sort\Random
Same name and namespace in other branches
  1. 8 core/modules/views/src/Plugin/views/sort/Random.php \Drupal\views\Plugin\views\sort\Random
  2. 9 core/modules/views/src/Plugin/views/sort/Random.php \Drupal\views\Plugin\views\sort\Random

Handle a random sort.

Plugin annotation

@ViewsSort("random");

Hierarchy

Expanded class hierarchy of Random

2 string references to 'Random'
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().

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;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
Random::buildOptionsForm public function Basic options for all sort criteria. Overrides SortPluginBase::buildOptionsForm
Random::query public function Called to add the sort to a query. Overrides SortPluginBase::query
Random::usesGroupBy public function
SortPluginBase::adminSummary public function Display whether or not the sort order is ascending or descending.
SortPluginBase::buildExposeForm public function
SortPluginBase::canExpose public function Determine if a sort can be exposed.
SortPluginBase::defaultExposeOptions public function Provide default options for exposed sorts.
SortPluginBase::defineOptions protected function 1
SortPluginBase::showExposeButton public function Shortcut to display the expose/hide button.
SortPluginBase::showSortForm protected function Shortcut to display the value form.
SortPluginBase::sortOptions protected function Provide a list of options for the default sort form.
SortPluginBase::sortSubmit public function
SortPluginBase::sortValidate protected function
SortPluginBase::submitOptionsForm public function Simple submit handler.
SortPluginBase::trustedCallbacks public static function
SortPluginBase::validateExposeForm public function Validate the options form.
SortPluginBase::validateOptionsForm public function Simple validate handler.
UncacheableDependencyTrait::getCacheContexts public function
UncacheableDependencyTrait::getCacheMaxAge public function
UncacheableDependencyTrait::getCacheTags public function