Skip to content
Snippets Groups Projects
Commit c384c34c authored by Lily Yan's avatar Lily Yan
Browse files

Merge branch 'feature/ISTWCMS-6804-ibiki-dashboard_webform_list_builder' into '1.0.x'

Feature/istwcms 6804 ibiki dashboard webform list builder

See merge request !34
parents e0cd6ca9 f87730e9
No related branches found
No related tags found
1 merge request!34Feature/istwcms 6804 ibiki dashboard webform list builder
<?php
namespace Drupal\uw_dashboard\Handler;
use Drupal\webform\WebformEntityListBuilder;
/**
* Class UWWebformEntityListBuilder.
*
* Extends functionality by updating one method.
*/
class UWWebformEntityListBuilder extends WebformEntityListBuilder {
/**
* New function that modifies output of parent render.
*
* Only usage is on uw_dashboard, when webform filter autocomplete
* matches one webform. This update will remove webform id, and
* use filter to display one result, which creates redirect otherwise.
*/
public function uwRender() {
if ($this->keys && preg_match('#\(([^)]+)\)$#', $this->keys, $match) && !empty($match[0])) {
$this->keys = trim(preg_replace('#\(([^)]+)\)$#', '', $this->keys));
}
return $this->render();
}
}
...@@ -99,13 +99,13 @@ class FormsListBlock extends BlockBase implements ContainerFactoryPluginInterfac ...@@ -99,13 +99,13 @@ class FormsListBlock extends BlockBase implements ContainerFactoryPluginInterfac
} }
// Get the render array from the entity list. // Get the render array from the entity list.
$render = $entity_type_list->render(); $render = $entity_type_list->uwRender();
// Remove the category filer. // Remove the category filer.
unset($render['filter_form']['filter']['category']); unset($render['filter_form']['filter']['category']);
} }
else { else {
$render = $entity_type_list->render(); $render = $entity_type_list->uwRender();
} }
// Render the entity list. // Render the entity list.
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
use Drupal\Core\Url; use Drupal\Core\Url;
use Drupal\user\Entity\User; use Drupal\user\Entity\User;
use Drupal\uw_dashboard\Handler\UWWebformEntityListBuilder;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
/** /**
...@@ -112,3 +113,12 @@ function uw_dashboard_preprocess_block(&$variables) { ...@@ -112,3 +113,12 @@ function uw_dashboard_preprocess_block(&$variables) {
} }
} }
} }
/**
* Implements hook_entity_type_alter().
*/
function uw_dashboard_entity_type_alter(array &$entity_types) {
// Replacing webform's default entity list builder with new child class.
// This should ensure all works as before, except is new function is called.
$entity_types['webform']->setHandlerClass('list_builder', UWWebformEntityListBuilder::class);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment