You are here

public function ResultsController::getResults in FullCalendar 8.4

Same name and namespace in other branches
  1. 8.5 src/Controller/ResultsController.php \Drupal\fullcalendar\Controller\ResultsController::getResults()
  2. 8 src/Controller/ResultsController.php \Drupal\fullcalendar\Controller\ResultsController::getResults()
  3. 8.2 src/Controller/ResultsController.php \Drupal\fullcalendar\Controller\ResultsController::getResults()
  4. 8.3 src/Controller/ResultsController.php \Drupal\fullcalendar\Controller\ResultsController::getResults()

Ajax callback to refresh calendar view.

Parameters

\Drupal\views\Entity\View $view: Fully-loaded view entity.

string $display_id: Display ID.

Return value

\Drupal\Core\Ajax\AjaxResponse|void

1 string reference to 'ResultsController::getResults'
fullcalendar.routing.yml in ./fullcalendar.routing.yml
fullcalendar.routing.yml

File

src/Controller/ResultsController.php, line 25

Class

ResultsController
Controller for handling ajax requests.

Namespace

Drupal\fullcalendar\Controller

Code

public function getResults(View $view, $display_id) {
  $response = new AjaxResponse();
  if (!$view) {
    return $response;
  }
  $view = $view
    ->getExecutable();
  if (!$view
    ->access($display_id)) {
    return $response;
  }
  if (!$view
    ->setDisplay($display_id)) {
    return $response;
  }
  $request = \Drupal::request();
  $args = $request->request
    ->get('view_args', '');
  $args = explode('/', $args);
  $view
    ->setExposedInput($request->request
    ->all());
  $view
    ->preExecute($args);
  $view
    ->execute($display_id);
  $content = $view
    ->buildRenderable($display_id, $args);
  $rendered = \Drupal::service('renderer')
    ->renderRoot($content);
  $response
    ->addCommand(new ResultsCommand($rendered));
  return $response;
}