3 namespace Drupal\views;
5 use Drupal\Core\Routing\RouteProviderInterface;
6 use Drupal\Core\Session\AccountInterface;
7 use Symfony\Component\HttpFoundation\RequestStack;
10 * Defines the cache backend factory.
12 class ViewExecutableFactory {
15 * Stores the current user.
17 * @var \Drupal\Core\Session\AccountInterface
24 * @var \Symfony\Component\HttpFoundation\RequestStack
26 protected $requestStack;
31 * @var \Drupal\views\ViewsData
38 * @var \Drupal\Core\Routing\RouteProviderInterface
40 protected $routeProvider;
43 * Constructs a new ViewExecutableFactory
45 * @param \Drupal\Core\Session\AccountInterface $user
47 * @param \Symfony\Component\HttpFoundation\RequestStack $request_stack
49 * @param \Drupal\views\ViewsData $views_data
51 * @param \Drupal\Core\Routing\RouteProviderInterface $route_provider
54 public function __construct(AccountInterface $user, RequestStack $request_stack, ViewsData $views_data, RouteProviderInterface $route_provider) {
56 $this->requestStack = $request_stack;
57 $this->viewsData = $views_data;
58 $this->routeProvider = $route_provider;
62 * Instantiates a ViewExecutable class.
64 * @param \Drupal\views\ViewEntityInterface $view
65 * A view entity instance.
67 * @return \Drupal\views\ViewExecutable
68 * A ViewExecutable instance.
70 public function get(ViewEntityInterface $view) {
71 $view = new ViewExecutable($view, $this->user, $this->viewsData, $this->routeProvider);
72 $view->setRequest($this->requestStack->getCurrentRequest());