diff --git a/core/modules/views/src/Plugin/views/row/RowPluginBase.php b/core/modules/views/src/Plugin/views/row/RowPluginBase.php index b13a96b..582dd09 100644 --- a/core/modules/views/src/Plugin/views/row/RowPluginBase.php +++ b/core/modules/views/src/Plugin/views/row/RowPluginBase.php @@ -121,6 +121,7 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { parent::buildOptionsForm($form, $form_state); if (isset($this->base_table)) { $executable = $this->executableFactory->get($form_state->get('view')); + $executable->initDisplay(); // A whole bunch of code to figure out what relationships are valid for // this item. diff --git a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php index 9be3036..2ae57b4 100644 --- a/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php +++ b/core/modules/views/tests/src/Unit/EventSubscriber/RouteSubscriberTest.php @@ -41,6 +41,13 @@ class RouteSubscriberTest extends UnitTestCase { protected $routeSubscriber; /** + * The mocked view executable. + * + * @var \Drupal\views\ViewExecutableFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewExecutableFactory; + + /** * The mocked key value storage. * * @var \Drupal\Core\State\StateInterface|\PHPUnit_Framework_MockObject_MockObject @@ -56,8 +63,11 @@ protected function setUp() { ->method('getStorage') ->with('view') ->will($this->returnValue($this->viewStorage)); + $this->viewExecutableFactory = $this->getMockBuilder('Drupal\views\ViewExecutableFactory') + ->disableOriginalConstructor() + ->getMock(); $this->state = $this->getMock('\Drupal\Core\State\StateInterface'); - $this->routeSubscriber = new TestRouteSubscriber($this->entityManager, $this->state); + $this->routeSubscriber = new TestRouteSubscriber($this->entityManager, $this->state, $this->viewExecutableFactory); } /** diff --git a/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php b/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php index fd7d497..baf8f22 100644 --- a/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php +++ b/core/modules/views/tests/src/Unit/Plugin/area/ViewTest.php @@ -31,12 +31,22 @@ class ViewTest extends UnitTestCase { protected $viewHandler; /** + * The mocked view executable. + * + * @var \Drupal\views\ViewExecutableFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewExecutableFactory; + + /** * {@inheritdoc} */ protected function setUp() { parent::setUp(); $this->entityStorage = $this->getMock('Drupal\Core\Entity\EntityStorageInterface'); - $this->viewHandler = new ViewAreaPlugin(array(), 'view', array(), $this->entityStorage); + $this->viewExecutableFactory = $this->getMockBuilder('Drupal\views\ViewExecutableFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->viewHandler = new ViewAreaPlugin(array(), 'view', array(), $this->entityStorage, $this->viewExecutableFactory); $this->viewHandler->view = $this->getMockBuilder('Drupal\views\ViewExecutable') ->disableOriginalConstructor() ->getMock(); diff --git a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php index 614aa29..96a8c86 100644 --- a/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php +++ b/core/modules/views/tests/src/Unit/ViewsHandlerManagerTest.php @@ -44,6 +44,13 @@ class ViewsHandlerManagerTest extends UnitTestCase { protected $factory; /** + * The mocked view executable. + * + * @var \Drupal\views\ViewExecutableFactory|\PHPUnit_Framework_MockObject_MockObject + */ + protected $viewExecutableFactory; + + /** * {@inheritdoc} */ public function setUp() { @@ -52,7 +59,10 @@ public function setUp() { ->getMock(); $cache_backend = $this->getMock('Drupal\Core\Cache\CacheBackendInterface'); $this->moduleHandler = $this->getMock('Drupal\Core\Extension\ModuleHandlerInterface'); - $this->handlerManager = new ViewsHandlerManager('test', new \ArrayObject(array()), $this->viewsData, $cache_backend, $this->moduleHandler); + $this->viewExecutableFactory = $this->getMockBuilder('Drupal\views\ViewExecutableFactory') + ->disableOriginalConstructor() + ->getMock(); + $this->handlerManager = new ViewsHandlerManager('test', new \ArrayObject(array()), $this->viewsData, $cache_backend, $this->moduleHandler, $this->viewExecutableFactory); } /** diff --git a/core/modules/views_ui/src/ViewEditForm.php b/core/modules/views_ui/src/ViewEditForm.php index 4ad0fb0..ccd3ac8 100644 --- a/core/modules/views_ui/src/ViewEditForm.php +++ b/core/modules/views_ui/src/ViewEditForm.php @@ -337,8 +337,8 @@ public function save(array $form, FormStateInterface $form_state) { continue; } - if (($display->getPluginId() == 'page') && ($old_path == $destination) && ($old_path != $this->executableFactory->get($view)->displayHandlers->get($id)->getOption('path'))) { - $destination = $this->executableFactory->get($view)->displayHandlers->get($id)->getOption('path'); + if (($display->getPluginId() == 'page') && ($old_path == $destination) && ($old_path != $executable->displayHandlers->get($id)->getOption('path'))) { + $destination = $executable->displayHandlers->get($id)->getOption('path'); $query->remove('destination'); } } @@ -647,7 +647,9 @@ public function submitDisplayEnable($form, FormStateInterface $form_state) { public function submitDisplayDisable($form, FormStateInterface $form_state) { $view = $this->entity; $id = $form_state->get('display_id'); - $this->executableFactory->get($view)->displayHandlers->get($id)->setOption('enabled', FALSE); + $executable = $this->executableFactory->get($view); + $executable->initDisplay(); + $executable->displayHandlers->get($id)->setOption('enabled', FALSE); // Store in cache $view->cacheSet(); @@ -838,7 +840,7 @@ public function submitDelayDestination($form, FormStateInterface $form_state) { public function submitDisplayDuplicate($form, FormStateInterface $form_state) { $view = $this->entity; $display_id = $this->displayID; - $executable = &$this->executableFactory->get($view); + $executable = $this->executableFactory->get($view); // Create the new display. $displays = $view->get('display'); @@ -865,7 +867,7 @@ public function submitDisplayDuplicate($form, FormStateInterface $form_state) { */ public function submitDisplayAdd($form, FormStateInterface $form_state) { $view = $this->entity; - $executable = &$this->executableFactory->get($view); + $executable = $this->executableFactory->get($view); // Create the new display. $parents = $form_state->getTriggeringElement()['#parents']; $display_type = array_pop($parents); diff --git a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php index a42a879..817f39c 100644 --- a/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php +++ b/core/modules/views_ui/tests/src/Unit/ViewListBuilderTest.php @@ -134,7 +134,7 @@ public function testBuildRowEntityList() { // Setup a view list builder with a mocked buildOperations method, // because t() is called on there. $entity_type = $this->getMock('Drupal\Core\Entity\EntityTypeInterface'); - $view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager); + $view_list_builder = new TestViewListBuilder($entity_type, $storage, $display_manager, $executable_factory); $view_list_builder->setStringTranslation($this->getStringTranslationStub()); $view = new View($values, 'view');