diff -u b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityOperations.php b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityOperations.php --- b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityOperations.php +++ b/core/modules/views/lib/Drupal/views/Plugin/views/field/EntityOperations.php @@ -7,7 +7,7 @@ namespace Drupal\views\Plugin\views\field; -use Drupal\Core\Entity\EntityListControllerInterface; +use Drupal\Core\Entity\EntityManagerInterface; use Drupal\views\ResultRow; use Symfony\Component\DependencyInjection\ContainerInterface; @@ -16,39 +16,39 @@ * * @ingroup views_field_handlers * - * @PluginID("views_entity_operations") + * @PluginID("entity_operations") */ class EntityOperations extends FieldPluginBase { /** - * The entity list. + * The entity manager. * - * @var \Drupal\Core\Entity\EntityListControllerInterface + * @var \Drupal\Core\Entity\EntityManagerInterface */ - protected $entityList; + protected $entityManager; /** * Constructor. * * @param array $configuration + * A configuration array containing information about the plugin instance. * @param string $plugin_id + * The plugin_id for the plugin instance. * @param array $plugin_definition - * @param \Drupal\Core\Entity\EntityListControllerInterface $entity_list - * The list controller of the entity type. + * The plugin implementation definition. + * @param \Drupal\Core\Entity\EntityManagerInterface $entity_manager + * The entity manager. */ - public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityListControllerInterface $entity_list) { + public function __construct(array $configuration, $plugin_id, array $plugin_definition, EntityManagerInterface $entity_manager) { parent::__construct($configuration, $plugin_id, $plugin_definition); - - $this->entityList = $entity_list; + $this->entityManager = $entity_manager; } /** * {@inheritdoc} */ public static function create(ContainerInterface $container, array $configuration, $plugin_id, array $plugin_definition) { - /** @var \Drupal\Core\Entity\EntityManagerInterface $entity_manager */ - $entity_manager = $container->get('entity.manager'); - return new static($configuration, $plugin_id, $plugin_definition, $entity_manager->getListController($plugin_definition['entity_type'])); + return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager')); } /** @@ -80,7 +80,7 @@ $form['destination'] = array( '#type' => 'checkbox', - '#title' => t('Include destination'), + '#title' => $this->t('Include destination'), '#description' => $this->t('Include a destination parameter in the link to return the user to the original view upon completing the link action.'), '#default_value' => $this->options['destination'], ); @@ -92,9 +92,12 @@ public function render(ResultRow $values) { $entity = $this->getEntity($values); if ($entity) { - $operations = $this->entityList->getOperations($entity); + $operations = $this->entityManager->getListController($this->getEntityType())->getOperations($entity); if ($this->options['destination']) { foreach ($operations as &$operation) { + if (!isset($operation['options']['query'])) { + $operation['options']['query'] = array(); + } $operation['options']['query'] += $this->drupalGetDestination(); } } @@ -115,2 +118,8 @@ } + + /** + * {@inheritdoc} + */ + public function query() { + } } diff -u b/core/modules/views/lib/Drupal/views/Tests/Plugin/views/field/EntityOperationsUnitTest.php b/core/modules/views/lib/Drupal/views/Tests/Plugin/views/field/EntityOperationsUnitTest.php --- b/core/modules/views/lib/Drupal/views/Tests/Plugin/views/field/EntityOperationsUnitTest.php +++ b/core/modules/views/lib/Drupal/views/Tests/Plugin/views/field/EntityOperationsUnitTest.php @@ -14,11 +14,11 @@ class EntityOperationsUnitTest extends UnitTestCase { /** - * The entity list used for testing. + * The entity manager used for testing. * - * @var \Drupal\Core\Entity\EntityListControllerInterface|\PHPUnit_Framework_MockObject_MockObject + * @var \Drupal\Core\Entity\EntityManagerInterface|\PHPUnit_Framework_MockObject_MockObject */ - protected $entityList; + protected $entityManager; /** * The plugin under test. @@ -42,13 +42,13 @@ * {@inheritdoc} */ public function setUp() { - $this->entityList = $this->getMock('\Drupal\Core\Entity\EntityListControllerInterface'); + $this->entityManager = $this->getMock('\Drupal\Core\Entity\EntityManagerInterface'); $configuration = array(); $plugin_id = $this->randomName(); $plugin_definition = array(); $this->plugin = $this->getMockBuilder('\Drupal\views\Plugin\views\field\EntityOperations') - ->setConstructorArgs(array($configuration, $plugin_id, $plugin_definition, $this->entityList)) + ->setConstructorArgs(array($configuration, $plugin_id, $plugin_definition, $this->entityManager)) ->setMethods(array('drupalGetDestination', 'getEntity', 't')) ->getMock(); } only in patch2: unchanged: --- a/core/modules/node/config/views.view.content.yml +++ b/core/modules/node/config/views.view.content.yml @@ -244,54 +244,6 @@ display: timezone: '' plugin_id: date provider: views - edit_node: - id: edit_node - table: node - field: edit_node - label: '' - exclude: true - text: Edit - plugin_id: node_link_edit - provider: node - delete_node: - id: delete_node - table: node - field: delete_node - label: '' - exclude: true - text: Delete - plugin_id: node_link_delete - provider: node - translation_link: - id: translation_link - table: node - field: translation_link - label: '' - exclude: true - alter: - alter_text: false - element_class: '' - element_default_classes: true - hide_alter_empty: true - hide_empty: false - empty_zero: false - empty: '' - text: Translate - optional: '1' - plugin_id: content_translation_link - provider: content_translation - dropbutton: - id: dropbutton - table: views - field: dropbutton - label: Operations - fields: - edit_node: edit_node - delete_node: delete_node - translation_link: translation_link - destination: '1' - plugin_id: dropbutton - provider: views timestamp: id: timestamp table: history @@ -344,6 +296,57 @@ display: comments: '0' plugin_id: history_user_timestamp provider: history + operations: + id: operations + table: node + field: operations + relationship: none + group_type: group + admin_label: '' + label: Operations + exclude: 0 + alter: + alter_text: 0 + text: '' + make_link: 0 + path: '' + absolute: 0 + external: 0 + replace_spaces: 0 + path_case: none + trim_whitespace: 0 + alt: '' + rel: '' + link_class: '' + prefix: '' + suffix: '' + target: '' + nl2br: 0 + max_length: '' + word_boundary: 1 + ellipsis: 1 + more_link: 0 + more_link_text: '' + more_link_path: '' + strip_tags: 0 + trim: 0 + preserve_tags: '' + html: 0 + element_type: '' + element_class: '' + element_label_type: '' + element_label_class: '' + element_label_colon: 1 + element_wrapper_type: '' + element_wrapper_class: '' + element_default_classes: 1 + empty: '' + hide_empty: 0 + empty_zero: 0 + hide_alter_empty: 1 + destination: 1 + plugin_id: entity_operations + provider: views filters: status_extra: id: status_extra only in patch2: unchanged: --- a/core/modules/node/node.views.inc +++ b/core/modules/node/node.views.inc @@ -214,6 +214,14 @@ function node_views_data() { ), ); + $data['node']['operations'] = array( + 'field' => array( + 'title' => t('Operations links'), + 'help' => t('Provide links to perform content operations.'), + 'id' => 'entity_operations', + ), + ); + $data['node']['view_node'] = array( 'field' => array( 'title' => t('Link to content'),