Issue #1898926 by damiankloip: Allow ViewExecutable to be pluggable.
parent
530c4c4541
commit
2ee77e4315
|
@ -139,7 +139,7 @@ class View extends ConfigEntityBase implements ViewStorageInterface {
|
|||
public function get($property_name, $langcode = NULL) {
|
||||
// Ensure that an executable View is available.
|
||||
if ($property_name == 'executable' && !isset($this->{$property_name})) {
|
||||
$this->set('executable', new ViewExecutable($this));
|
||||
$this->set('executable', drupal_container()->get('views.executable')->get($this));
|
||||
}
|
||||
|
||||
return parent::get($property_name, $langcode);
|
||||
|
|
|
@ -123,7 +123,7 @@ class DefaultViewsTest extends WebTestBase {
|
|||
$views = $controller->load();
|
||||
|
||||
foreach ($views as $name => $view_storage) {
|
||||
$view = new ViewExecutable($view_storage);
|
||||
$view = $view_storage->get('executable');
|
||||
$view->initDisplay();
|
||||
foreach ($view->storage->get('display') as $display_id => $display) {
|
||||
$view->setDisplay($display_id);
|
||||
|
|
|
@ -60,7 +60,7 @@ class HandlerAllTest extends HandlerTestBase {
|
|||
}
|
||||
|
||||
$view = entity_create('view', array('base_table' => $base_table));
|
||||
$view = new ViewExecutable($view);
|
||||
$view = $view->get('executable');
|
||||
|
||||
// @todo The groupwise relationship is currently broken.
|
||||
$exclude[] = 'taxonomy_term_data:tid_representative';
|
||||
|
|
|
@ -9,6 +9,7 @@ namespace Drupal\views\Tests;
|
|||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Drupal\views\ViewExecutable;
|
||||
use Drupal\views\ViewExecutableFactory;
|
||||
use Drupal\views\DisplayBag;
|
||||
use Drupal\views\Plugin\views\display\DefaultDisplay;
|
||||
use Drupal\views\Plugin\views\display\Page;
|
||||
|
@ -81,6 +82,16 @@ class ViewExecutableTest extends ViewUnitTestBase {
|
|||
$this->enableModules(array('system', 'node', 'comment', 'user', 'filter'));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the views.exectuable container service.
|
||||
*/
|
||||
public function testFactoryService() {
|
||||
$factory = $this->container->get('views.executable');
|
||||
$this->assertTrue($factory instanceof ViewExecutableFactory, 'A ViewExecutableFactory instance was returned from the container.');
|
||||
$view = entity_load('view', 'test_executable_displays');
|
||||
$this->assertTrue($factory->get($view) instanceof ViewExecutable, 'A ViewExecutable instance was returned from the factory.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the initDisplay() and initHandlers() methods.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\views\ViewExecutableFactory.
|
||||
*/
|
||||
|
||||
namespace Drupal\views;
|
||||
|
||||
use Drupal\views\Plugin\Core\Entity\View;
|
||||
|
||||
/**
|
||||
* Defines the cache backend factory.
|
||||
*/
|
||||
class ViewExecutableFactory {
|
||||
|
||||
/**
|
||||
* Instantiates a ViewExecutable class.
|
||||
*
|
||||
* @param \Drupal\views\Plugin\Core\Entity\View $view
|
||||
* A view entity instance.
|
||||
*
|
||||
* @return \Drupal\views\ViewExecutable
|
||||
* A ViewExecutable instance.
|
||||
*/
|
||||
public static function get(View $view) {
|
||||
return new ViewExecutable($view);
|
||||
}
|
||||
|
||||
}
|
|
@ -35,6 +35,8 @@ class ViewsBundle extends Bundle {
|
|||
$container->register('views.views_data', 'Drupal\views\ViewsDataCache')
|
||||
->addArgument(new Reference('cache.views_info'))
|
||||
->addArgument(new Reference('config.factory'));
|
||||
|
||||
$container->register('views.executable', 'Drupal\views\ViewExecutableFactory');
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue