protected function JsBase::createFacet in Facets 8
Create a facet.
Parameters
string $id: The id of the facet.
string $field: The field name.
string $widget_type: The type of the facet widget. links by default.
array $widget_settings: The widget config.
Throws
\Drupal\Component\Plugin\Exception\InvalidPluginDefinitionException
\Drupal\Component\Plugin\Exception\PluginNotFoundException
\Drupal\Core\Entity\EntityStorageException
4 calls to JsBase::createFacet()
- AjaxBehaviorTest::testAjaxCheckbox in tests/
src/ FunctionalJavascript/ AjaxBehaviorTest.php - Tests ajax checkbox.
- AjaxBehaviorTest::testAjaxDropdown in tests/
src/ FunctionalJavascript/ AjaxBehaviorTest.php - Tests ajax dropdown.
- AjaxBehaviorTest::testAjaxLinks in tests/
src/ FunctionalJavascript/ AjaxBehaviorTest.php - Tests ajax links.
- AjaxBehaviorTest::testLinksWithExposedFilter in tests/
src/ FunctionalJavascript/ AjaxBehaviorTest.php - Tests links with exposed filters.
File
- tests/
src/ FunctionalJavascript/ JsBase.php, line 151
Class
- JsBase
- Tests for the JS that transforms widgets into form elements.
Namespace
Drupal\Tests\facets\FunctionalJavascriptCode
protected function createFacet($id, $field = 'type', $widget_type = 'links', array $widget_settings = [
'show_numbers' => TRUE,
'soft_limit' => 0,
]) {
$facet_storage = \Drupal::entityTypeManager()
->getStorage('facets_facet');
// Create and save a facet with a checkbox widget.
$facet_storage
->create([
'id' => $id,
'name' => strtoupper($id),
'url_alias' => $id,
'facet_source_id' => 'search_api:views_page__search_api_test_view__page_1',
'field_identifier' => $field,
'empty_behavior' => [
'behavior' => 'none',
],
'weight' => 1,
'widget' => [
'type' => $widget_type,
'config' => $widget_settings,
],
'processor_configs' => [
'url_processor_handler' => [
'processor_id' => 'url_processor_handler',
'weights' => [
'pre_query' => -10,
'build' => -10,
],
'settings' => [],
],
],
'query_operator' => 'AND',
])
->save();
$this
->createBlock($id);
}