You are here

protected function PurgeBlockForm::gatherInvalidationsData in Purge 8.3

Gather information for the invalidation objects to be queued/purged.

Return value

string[] List of expressions to be queued/purged as invalidation objects.

1 call to PurgeBlockForm::gatherInvalidationsData()
PurgeBlockForm::buildForm in modules/purge_ui/src/Form/PurgeBlockForm.php
Form constructor.

File

modules/purge_ui/src/Form/PurgeBlockForm.php, line 131

Class

PurgeBlockForm
End-user form for \Drupal\purge_ui\Plugin\Block\PurgeBlock.

Namespace

Drupal\purge_ui\Form

Code

protected function gatherInvalidationsData() {
  $request = $this
    ->getRequest();
  $expressions = [];
  switch ($this->config['type']) {
    case 'url':
      $expressions[] = $request
        ->getUriForPath($request
        ->getRequestUri());
      $expressions[] = $request
        ->getUri();
      $expressions[] = str_replace('?' . $request
        ->getQueryString(), '', $expressions[1]);
      break;
    case 'path':
      $expressions[] = ltrim($request
        ->getRequestUri(), '/');
      $expressions[] = explode('?', $expressions[0])[0];
      break;
    case 'everything':
      $expressions[] = NULL;
      break;
  }
  return array_unique($expressions);
}