Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
facets
Commits
10bc6657
Commit
10bc6657
authored
Oct 09, 2015
by
marthinal
Browse files
render facet
parent
c5e99b31
Changes
7
Hide whitespace changes
Inline
Side-by-side
config/schema/facetapi.facet.schema.yml
View file @
10bc6657
...
...
@@ -20,6 +20,9 @@ facetapi.facet.*:
field_identifier
:
type
:
string
label
:
'
Field
identifier'
query_type_name
:
type
:
string
label
:
'
Query
Type
Name'
widget
:
type
:
string
label
:
'
Field
identifier'
...
...
src/Adapter/AdapterInterface.php
View file @
10bc6657
...
...
@@ -144,4 +144,6 @@ interface AdapterInterface {
*/
public
function
build
(
$facet
);
public
function
setResults
(
$facet
);
}
src/Adapter/AdapterPluginBase.php
View file @
10bc6657
...
...
@@ -267,6 +267,8 @@ abstract class AdapterPluginBase extends PluginBase implements AdapterInterface,
$search_id
=
$this
->
searcher_id
;
foreach
(
$this
->
facets
as
$facet
)
{
// Only if the facet is for this query, alter the query.
// @TODO use the line for tests only.
//if ($facet->getName() == 'entity:node/uid' || $facet->getName() == 'entity:node/type') {
if
(
$facet
->
getFacetSource
()
==
$search_id
)
{
// Create the query type plugin.
$query_type_plugin
=
$this
->
query_type_plugin_manager
->
createInstance
(
$facet
->
getQueryType
(),
...
...
@@ -340,15 +342,16 @@ abstract class AdapterPluginBase extends PluginBase implements AdapterInterface,
$url_processor
->
processFacet
(
$facet
);
}
}
}
public
function
build
(
$facet
)
{
// Process the facets.
// @TODO: inject the searcher id on create of the adapter.
$this
->
searcher_id
=
$facet
->
getFacetSource
();
// @TODO: Should we update facets each time we build a block?
//$this->processFacets();
$facet
=
$this
->
setResults
(
$facet
);
$this
->
processFacets
();
// Let the plugin render the facet.
// @TODO: functionality to alter the state of the facet should
...
...
src/Entity/Facet.php
View file @
10bc6657
...
...
@@ -39,6 +39,7 @@ use Drupal\facetapi\Result\ResultInterface;
* "id",
* "name",
* "field_identifier",
* "query_type_name",
* "facet_source",
* "widget",
* "widget_configs",
...
...
@@ -146,6 +147,8 @@ class Facet extends ConfigEntityBase implements FacetInterface {
*/
public
function
__construct
(
array
$values
,
$entity_type
)
{
parent
::
__construct
(
$values
,
$entity_type
);
// @TODO Added only for test.
$this
->
query_type_name
=
'search_api_term'
;
}
/**
...
...
@@ -251,6 +254,8 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return
$this
->
query_type_name
;
}
public
function
getUrlProcessorName
()
{
return
$this
->
url_processor_name
;
}
...
...
src/Plugin/facetapi/adapter/SearchApiViewsAdapter.php
View file @
10bc6657
...
...
@@ -97,4 +97,23 @@ class SearchApiViewsAdapter extends AdapterPluginBase {
}
public
function
setResults
(
$facet
)
{
$results
=
$this
->
searchResultsCache
->
getResults
(
$this
->
searcher_id
);
$facet_results
=
$results
->
getExtraData
(
'search_api_facets'
);
$configuration
=
array
(
'query'
=>
NULL
,
'facet'
=>
$facet
,
'results'
=>
$facet_results
[
$facet
->
getFieldIdentifier
()],
);
// @TODO The query type is not added to the facet.
//$facet->getQueryType()
$query_type_plugin
=
$this
->
query_type_plugin_manager
->
createInstance
(
$facet
->
getQueryType
(),
$configuration
);
return
$query_type_plugin
->
build
();
}
}
src/Plugin/facetapi/query_type/QueryTypeTerm.php
View file @
10bc6657
...
...
@@ -71,5 +71,6 @@ class QueryTypeTerm extends QueryTypePluginBase {
}
$this
->
facet
->
setResults
(
$facet_results
);
}
return
$this
->
facet
;
}
}
\ No newline at end of file
src/Plugin/facetapi/widget/LinksWidget.php
View file @
10bc6657
...
...
@@ -42,7 +42,7 @@ class LinksWidget implements WidgetInterface {
$text
=
'(-) '
.
$text
;
}
$link_generator
=
\
Drupal
::
linkGenerator
();
$link
=
$link_generator
->
generate
(
$text
,
$result
->
getUrl
());
$link
=
$text
;
//
$link_generator->generate($text, $result->getUrl());
$items
[]
=
$link
;
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment