1<?php 2 3namespace Drupal\views; 4 5use Drupal\Core\Routing\RouteProviderInterface; 6use Drupal\Core\Session\AccountInterface; 7use Symfony\Component\HttpFoundation\RequestStack; 8 9/** 10 * Defines the cache backend factory. 11 */ 12class ViewExecutableFactory { 13 14 /** 15 * Stores the current user. 16 * 17 * @var \Drupal\Core\Session\AccountInterface 18 */ 19 protected $user; 20 21 /** 22 * The request stack. 23 * 24 * @var \Symfony\Component\HttpFoundation\RequestStack 25 */ 26 protected $requestStack; 27 28 /** 29 * The views data. 30 * 31 * @var \Drupal\views\ViewsData 32 */ 33 protected $viewsData; 34 35 /** 36 * The route provider. 37 * 38 * @var \Drupal\Core\Routing\RouteProviderInterface 39 */ 40 protected $routeProvider; 41 42 /** 43 * Constructs a new ViewExecutableFactory. 44 * 45 * @param \Drupal\Core\Session\AccountInterface $user 46 * The current user. 47 * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack 48 * The request stack. 49 * @param \Drupal\views\ViewsData $views_data 50 * The views data. 51 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider 52 * The route provider. 53 */ 54 public function __construct(AccountInterface $user, RequestStack $request_stack, ViewsData $views_data, RouteProviderInterface $route_provider) { 55 $this->user = $user; 56 $this->requestStack = $request_stack; 57 $this->viewsData = $views_data; 58 $this->routeProvider = $route_provider; 59 } 60 61 /** 62 * Instantiates a ViewExecutable class. 63 * 64 * @param \Drupal\views\ViewEntityInterface $view 65 * A view entity instance. 66 * 67 * @return \Drupal\views\ViewExecutable 68 * A ViewExecutable instance. 69 */ 70 public function get(ViewEntityInterface $view) { 71 $view_executable = new ViewExecutable($view, $this->user, $this->viewsData, $this->routeProvider); 72 $view_executable->setRequest($this->requestStack->getCurrentRequest()); 73 return $view_executable; 74 } 75 76} 77