Loading config_view.module +10 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ function config_view_views_data() { $table = &$data[$id]; $table['table']['group'] = $name; $table['table']['provider'] = $id; $table['table']['entity type'] = $id; $fields = ConfigViewHelper::getMapping($id); if (empty($fields['id'])) { Loading @@ -65,11 +66,19 @@ function config_view_views_data() { 'query_id' => 'config_view_query', ]; $table['operation'] = [ 'title' => t('Operations'), 'help' => t('Operations'), 'field' => [ 'id' => 'config_entity_operations', ], 'argument' => ['type' => $id], ]; // Dynamically adding suitable handlers for all indexed fields. foreach ($fields as $key => $value) { if (isset($value['label']) && isset($value['type'])) { $properties = ConfigViewHelper::getFieldParameters($value); if (!empty($properties)) { $table[$key] = [ 'title' => $value['label'], Loading src/Plugin/views/field/ConfigEntityOperations.php 0 → 100644 +30 −0 Original line number Diff line number Diff line <?php namespace Drupal\config_view\Plugin\views\field; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; /** * Field handler to display entity label optionally linked to entity page. * * @ViewsField("config_entity_operations") */ class ConfigEntityOperations extends FieldPluginBase { /** * {@inheritdoc} */ public function render(ResultRow $values) { // Doesn't work as there is no alias. // $value = $this->getValue($values, 'type');. $entity_type = $this->getEntityType(); $entity = $values->_relationship_objects[NULL][0]; $list_builder = \Drupal::entityTypeManager()->getListBuilder($entity_type); return [ '#type' => 'operations', '#links' => $list_builder->getOperations($entity), ]; } } Loading
config_view.module +10 −1 Original line number Diff line number Diff line Loading @@ -47,6 +47,7 @@ function config_view_views_data() { $table = &$data[$id]; $table['table']['group'] = $name; $table['table']['provider'] = $id; $table['table']['entity type'] = $id; $fields = ConfigViewHelper::getMapping($id); if (empty($fields['id'])) { Loading @@ -65,11 +66,19 @@ function config_view_views_data() { 'query_id' => 'config_view_query', ]; $table['operation'] = [ 'title' => t('Operations'), 'help' => t('Operations'), 'field' => [ 'id' => 'config_entity_operations', ], 'argument' => ['type' => $id], ]; // Dynamically adding suitable handlers for all indexed fields. foreach ($fields as $key => $value) { if (isset($value['label']) && isset($value['type'])) { $properties = ConfigViewHelper::getFieldParameters($value); if (!empty($properties)) { $table[$key] = [ 'title' => $value['label'], Loading
src/Plugin/views/field/ConfigEntityOperations.php 0 → 100644 +30 −0 Original line number Diff line number Diff line <?php namespace Drupal\config_view\Plugin\views\field; use Drupal\views\Plugin\views\field\FieldPluginBase; use Drupal\views\ResultRow; /** * Field handler to display entity label optionally linked to entity page. * * @ViewsField("config_entity_operations") */ class ConfigEntityOperations extends FieldPluginBase { /** * {@inheritdoc} */ public function render(ResultRow $values) { // Doesn't work as there is no alias. // $value = $this->getValue($values, 'type');. $entity_type = $this->getEntityType(); $entity = $values->_relationship_objects[NULL][0]; $list_builder = \Drupal::entityTypeManager()->getListBuilder($entity_type); return [ '#type' => 'operations', '#links' => $list_builder->getOperations($entity), ]; } }