Issue #2419905 by Arla: Views field 'Operations links' fails to set destination
parent
7e41973fc9
commit
c2f94345fc
|
@ -99,10 +99,10 @@ class EntityOperations extends FieldPluginBase {
|
|||
$operations = $this->entityManager->getListBuilder($entity->getEntityTypeId())->getOperations($entity);
|
||||
if ($this->options['destination']) {
|
||||
foreach ($operations as &$operation) {
|
||||
if (!isset($operation['options']['query'])) {
|
||||
$operation['options']['query'] = array();
|
||||
if (!isset($operation['query'])) {
|
||||
$operation['query'] = array();
|
||||
}
|
||||
$operation['options']['query'] += drupal_get_destination();
|
||||
$operation['query'] += drupal_get_destination();
|
||||
}
|
||||
}
|
||||
$build = array(
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
|
||||
namespace Drupal\views\Tests\Handler;
|
||||
|
||||
use Drupal\views\Tests\ViewUnitTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\entity_test\Entity\EntityTest;
|
||||
|
||||
/**
|
||||
* Tests the core Drupal\views\Plugin\views\field\EntityOperations handler.
|
||||
|
@ -29,28 +29,30 @@ class FieldEntityOperationsTest extends HandlerTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('node');
|
||||
public static $modules = array('entity_test');
|
||||
|
||||
/**
|
||||
* Tests entity operations field.
|
||||
*/
|
||||
public function testEntityOperations() {
|
||||
// Create some test nodes.
|
||||
$nodes = array();
|
||||
// Create some test entities.
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
$nodes[] = $this->drupalCreateNode();
|
||||
EntityTest::create(array(
|
||||
'name' => $this->randomString(),
|
||||
))->save();
|
||||
}
|
||||
$entities = EntityTest::loadMultiple();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(array('access administration pages', 'bypass node access'));
|
||||
$admin_user = $this->drupalCreateUser(array('access administration pages', 'administer entity_test content'));
|
||||
$this->drupalLogin($admin_user);
|
||||
$this->drupalGet('test-entity-operations');
|
||||
|
||||
/* @var $node \Drupal\node\NodeInterface */
|
||||
foreach ($nodes as $node) {
|
||||
$operations = \Drupal::entityManager()->getListBuilder('node')->getOperations($node);
|
||||
foreach ($entities as $entity) {
|
||||
$operations = \Drupal::entityManager()->getListBuilder('entity_test')->getOperations($entity);
|
||||
foreach ($operations as $operation) {
|
||||
$result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => $operation['url']->getInternalPath(), ':title' => $operation['title']));
|
||||
$this->assertEqual(count($result), 1, t('Found node @operation link.', array('@operation' => $operation['title'])));
|
||||
$expected_destination = Url::fromUri('user-path:/test-entity-operations');
|
||||
$result = $this->xpath('//ul[contains(@class, dropbutton)]/li/a[contains(@href, :path) and text()=:title]', array(':path' => $operation['url'] . '?destination=' . $expected_destination, ':title' => $operation['title']));
|
||||
$this->assertEqual(count($result), 1, t('Found entity @operation link with destination parameter.', array('@operation' => $operation['title'])));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -108,7 +108,7 @@ class EntityOperationsUnitTest extends UnitTestCase {
|
|||
'#type' => 'operations',
|
||||
'#links' => $operations
|
||||
);
|
||||
$expected_build['#links']['foo']['options']['query'] = drupal_get_destination();
|
||||
$expected_build['#links']['foo']['query'] = drupal_get_destination();
|
||||
$build = $this->plugin->render($result);
|
||||
$this->assertSame($expected_build, $build);
|
||||
}
|
||||
|
|
|
@ -2,15 +2,14 @@ langcode: und
|
|||
status: true
|
||||
dependencies:
|
||||
module:
|
||||
- node
|
||||
- user
|
||||
- entity_test
|
||||
id: test_entity_operations
|
||||
label: test_entity_operations
|
||||
module: views
|
||||
description: ''
|
||||
tag: ''
|
||||
base_table: node
|
||||
base_field: nid
|
||||
base_table: entity_test
|
||||
base_field: id
|
||||
core: 8.x
|
||||
display:
|
||||
default:
|
||||
|
@ -20,7 +19,7 @@ display:
|
|||
position: null
|
||||
display_options:
|
||||
access:
|
||||
type: perm
|
||||
type: none
|
||||
cache:
|
||||
type: none
|
||||
query:
|
||||
|
@ -36,16 +35,15 @@ display:
|
|||
row:
|
||||
type: fields
|
||||
fields:
|
||||
nid:
|
||||
id: nid
|
||||
table: node
|
||||
field: nid
|
||||
plugin_id: node
|
||||
name:
|
||||
id: name
|
||||
table: entity_test
|
||||
field: name
|
||||
relationship: none
|
||||
group_type: group
|
||||
admin_label: ''
|
||||
label: Nid
|
||||
exclude: true
|
||||
label: ''
|
||||
exclude: false
|
||||
alter:
|
||||
alter_text: false
|
||||
text: ''
|
||||
|
@ -77,7 +75,7 @@ display:
|
|||
element_class: ''
|
||||
element_label_type: ''
|
||||
element_label_class: ''
|
||||
element_label_colon: true
|
||||
element_label_colon: false
|
||||
element_wrapper_type: ''
|
||||
element_wrapper_class: ''
|
||||
element_default_classes: true
|
||||
|
@ -85,32 +83,12 @@ display:
|
|||
hide_empty: false
|
||||
empty_zero: false
|
||||
hide_alter_empty: true
|
||||
link_to_node: false
|
||||
entity_type: node
|
||||
entity_field: nid
|
||||
title:
|
||||
id: title
|
||||
table: node_field_data
|
||||
field: title
|
||||
plugin_id: node
|
||||
label: ''
|
||||
alter:
|
||||
alter_text: false
|
||||
make_link: false
|
||||
absolute: false
|
||||
trim: false
|
||||
word_boundary: false
|
||||
ellipsis: false
|
||||
strip_tags: false
|
||||
html: false
|
||||
hide_empty: false
|
||||
empty_zero: false
|
||||
link_to_node: true
|
||||
entity_type: node
|
||||
entity_field: title
|
||||
entity_type: entity_test
|
||||
entity_field: name
|
||||
plugin_id: standard
|
||||
operations:
|
||||
id: operations
|
||||
table: node
|
||||
table: entity_test
|
||||
field: operations
|
||||
relationship: none
|
||||
group_type: group
|
||||
|
@ -158,18 +136,7 @@ display:
|
|||
hide_alter_empty: true
|
||||
destination: true
|
||||
plugin_id: entity_operations
|
||||
filters:
|
||||
status:
|
||||
value: true
|
||||
table: node_field_data
|
||||
field: status
|
||||
id: status
|
||||
plugin_id: boolean
|
||||
expose:
|
||||
operator: '0'
|
||||
group: 1
|
||||
entity_type: node
|
||||
entity_field: status
|
||||
filters: { }
|
||||
sorts:
|
||||
created:
|
||||
id: created
|
||||
|
|
Loading…
Reference in New Issue