Loading core/modules/views/src/Plugin/views/field/EntityOperations.php +7 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,13 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function render(ResultRow $values) { $entity = $this->getEntityTranslation($this->getEntity($values), $values); $entity = $this->getEntity($values); // Allow for the case where there is no entity, if we are on a non-required // relationship. if (empty($entity)) { return ''; } $entity = $this->getEntityTranslation($entity, $values); $operations = $this->entityTypeManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity); if ($this->options['destination']) { foreach ($operations as &$operation) { Loading core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -174,4 +174,18 @@ public function testRenderWithoutDestination() { $this->assertSame($expected_build, $build); } /** * @covers ::render */ public function testRenderWithoutEntity() { $entity = NULL; $result = new ResultRow(); $result->_entity = $entity; $expected_build = ''; $build = $this->plugin->render($result); $this->assertSame($expected_build, $build); } } Loading
core/modules/views/src/Plugin/views/field/EntityOperations.php +7 −1 Original line number Diff line number Diff line Loading @@ -127,7 +127,13 @@ public function buildOptionsForm(&$form, FormStateInterface $form_state) { * {@inheritdoc} */ public function render(ResultRow $values) { $entity = $this->getEntityTranslation($this->getEntity($values), $values); $entity = $this->getEntity($values); // Allow for the case where there is no entity, if we are on a non-required // relationship. if (empty($entity)) { return ''; } $entity = $this->getEntityTranslation($entity, $values); $operations = $this->entityTypeManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity); if ($this->options['destination']) { foreach ($operations as &$operation) { Loading
core/modules/views/tests/src/Unit/Plugin/views/field/EntityOperationsUnitTest.php +14 −0 Original line number Diff line number Diff line Loading @@ -174,4 +174,18 @@ public function testRenderWithoutDestination() { $this->assertSame($expected_build, $build); } /** * @covers ::render */ public function testRenderWithoutEntity() { $entity = NULL; $result = new ResultRow(); $result->_entity = $entity; $expected_build = ''; $build = $this->plugin->render($result); $this->assertSame($expected_build, $build); } }