Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Open sidebar
project
facets
Commits
285101ea
Commit
285101ea
authored
Oct 06, 2015
by
StryKaizer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Facets are now not bound to search_api_indexes anymore. UI moved to seperate location
parent
bd63e508
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
39 additions
and
52 deletions
+39
-52
facetapi.links.action.yml
facetapi.links.action.yml
+1
-1
facetapi.links.menu.yml
facetapi.links.menu.yml
+6
-0
facetapi.links.task.yml
facetapi.links.task.yml
+0
-5
facetapi.module
facetapi.module
+1
-1
facetapi.routing.yml
facetapi.routing.yml
+7
-7
src/Controller/FacetController.php
src/Controller/FacetController.php
+5
-9
src/Entity/Facet.php
src/Entity/Facet.php
+4
-16
src/Form/FacetDeleteConfirmForm.php
src/Form/FacetDeleteConfirmForm.php
+2
-2
src/Form/FacetForm.php
src/Form/FacetForm.php
+12
-10
src/Tests/IntegrationTest.php
src/Tests/IntegrationTest.php
+1
-1
No files found.
facetapi.links.action.yml
View file @
285101ea
...
...
@@ -2,4 +2,4 @@ entity.facetapi_facet.add_form:
route_name
:
entity.facetapi_facet.add_form
title
:
'
Add
facet'
appears_on
:
-
entity.search_api_index.facets
-
facetapi.overview
facetapi.links.menu.yml
0 → 100644
View file @
285101ea
facetapi.overview
:
title
:
Facet API
description
:
'
Configure
facets
for
Search
API
searchers.'
route_name
:
facetapi.overview
weight
:
30
parent
:
system.admin_config_search
facetapi.links.task.yml
deleted
100644 → 0
View file @
bd63e508
entity.search_api_server.facets
:
route_name
:
entity.search_api_index.facets
base_route
:
entity.search_api_index.canonical
title
:
'
Facets'
weight
:
30
facetapi.module
View file @
285101ea
...
...
@@ -199,7 +199,7 @@ function facetapi_entity_operation_alter(array &$operations, \Drupal\Core\Entity
$operations
[
'facets'
]
=
array
(
'title'
=>
t
(
'Facets'
),
'weight'
=>
40
,
'url'
=>
Url
::
fromRoute
(
'
entity.search_api_index.facets
'
,
$route_parameters
),
'url'
=>
Url
::
fromRoute
(
'
facetapi.overview
'
,
$route_parameters
),
);
}
}
facetapi.routing.yml
View file @
285101ea
entity.search_api_index.facets
:
path
:
'
/admin/config/search/
search-api/index/{search_api_index}/facets
'
facetapi.overview
:
path
:
'
/admin/config/search/
facet-api
'
defaults
:
_title
:
'
Facet
s
'
_title
:
'
Facet
API
'
_entity_list
:
'
facetapi_facet'
requirements
:
_entity_create_access
:
'
search_api_index'
entity.facetapi_facet.add_form
:
path
:
'
/admin/config/search/
search-api/{search_api_index}/facets
/add-facet'
path
:
'
/admin/config/search/
facet-api
/add-facet'
defaults
:
_controller
:
'
\Drupal\facetapi\Controller\FacetController::addForm'
_title
:
'
Add
facet'
...
...
@@ -15,7 +15,7 @@ entity.facetapi_facet.add_form:
_entity_create_access
:
'
facetapi_facet'
entity.facetapi_facet.canonical
:
path
:
'
/admin/config/search/
search-api/index/{search_api_index}/facets
/{facetapi_facet}'
path
:
'
/admin/config/search/
facet-api
/{facetapi_facet}'
defaults
:
_controller
:
'
\Drupal\facetapi\Controller\FacetController::page'
_title_callback
:
'
\Drupal\facetapi\Controller\FacetController::pageTitle'
...
...
@@ -23,7 +23,7 @@ entity.facetapi_facet.canonical:
_entity_access
:
'
facetapi_facet.view'
entity.facetapi_facet.edit_form
:
path
:
'
/admin/config/search/
search-api/index/{search_api_index}/facets
/{facetapi_facet}/edit'
path
:
'
/admin/config/search/
facet-api
/{facetapi_facet}/edit'
defaults
:
_controller
:
'
\Drupal\facetapi\Controller\FacetController::editForm'
_title
:
'
Add
facet'
...
...
@@ -31,7 +31,7 @@ entity.facetapi_facet.edit_form:
_entity_access
:
'
facetapi_facet.edit'
entity.facetapi_facet.delete_form
:
path
:
'
/admin/config/search/
search-api/index/{search_api_index}/facets
/{facetapi_facet}/delete'
path
:
'
/admin/config/search/
facet-api
/{facetapi_facet}/delete'
defaults
:
_entity_form
:
'
facetapi_facet.delete'
requirements
:
...
...
src/Controller/FacetController.php
View file @
285101ea
...
...
@@ -46,11 +46,9 @@ class FacetController extends ControllerBase {
* @return array
* The facet add form.
*/
public
function
addForm
(
IndexInterface
$search_api_index
)
{
$facet
=
$this
->
entityManager
()
->
getStorage
(
'facetapi_facet'
)
->
create
(
array
(
'search_api_index'
=>
$search_api_index
->
id
()));
$form_state_additions
=
[
'search_api_index'
=>
$search_api_index
];
return
$this
->
entityFormBuilder
()
->
getForm
(
$facet
,
'default'
,
$form_state_additions
);
public
function
addForm
()
{
$facet
=
$this
->
entityManager
()
->
getStorage
(
'facetapi_facet'
)
->
create
();
return
$this
->
entityFormBuilder
()
->
getForm
(
$facet
,
'default'
);
}
/**
...
...
@@ -64,11 +62,9 @@ class FacetController extends ControllerBase {
* @return array
* The facet edit form.
*/
public
function
editForm
(
IndexInterface
$search_api_index
,
FacetInterface
$facetapi_facet
)
{
public
function
editForm
(
FacetInterface
$facetapi_facet
)
{
$facet
=
$this
->
entityManager
()
->
getStorage
(
'facetapi_facet'
)
->
load
(
$facetapi_facet
->
id
());
$form_state_additions
=
[
'search_api_index'
=>
$search_api_index
];
return
$this
->
entityFormBuilder
()
->
getForm
(
$facet
,
'default'
,
$form_state_additions
);
return
$this
->
entityFormBuilder
()
->
getForm
(
$facet
,
'default'
);
}
/**
...
...
src/Entity/Facet.php
View file @
285101ea
...
...
@@ -44,10 +44,10 @@ use Drupal\facetapi\Result\ResultInterface;
* "widget_configs",
* },
* links = {
* "canonical" = "/admin/config/search/
search-api/index/{search_api_index}/facets
",
* "add-form" = "/admin/config/search/
search-api/index/{search_api_index}/facets
/add-facet",
* "edit-form" = "/admin/config/search/
search-api/index/{search_api_index}/facets
/{facetapi_facet}/edit",
* "delete-form" = "/admin/config/search/
search-api/index/{search_api_index}/facets
/{facetapi_facet}/delete",
* "canonical" = "/admin/config/search/
facet-api
",
* "add-form" = "/admin/config/search/
facet-api
/add-facet",
* "edit-form" = "/admin/config/search/
facet-api
/{facetapi_facet}/edit",
* "delete-form" = "/admin/config/search/
facet-api
/{facetapi_facet}/delete",
* }
* )
*/
...
...
@@ -118,13 +118,6 @@ class Facet extends ConfigEntityBase implements FacetInterface {
*/
protected
$searcher_name
;
/**
* The search api index this facet belongs to.
*
* @var string
*/
protected
$search_api_index
;
/**
* The plugin name of the url processor.
*
...
...
@@ -264,16 +257,11 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return
$this
->
name
;
}
public
function
getSearchApiIndex
()
{
return
$this
->
search_api_index
;
}
/**
* {@inheritdoc}
*/
protected
function
urlRouteParameters
(
$rel
)
{
$parameters
=
parent
::
urlRouteParameters
(
$rel
);
$parameters
[
'search_api_index'
]
=
$this
->
getSearchApiIndex
();
return
$parameters
;
}
...
...
src/Form/FacetDeleteConfirmForm.php
View file @
285101ea
...
...
@@ -27,7 +27,7 @@ class FacetDeleteConfirmForm extends EntityConfirmFormBase {
* {@inheritdoc}
*/
public
function
getCancelUrl
()
{
return
new
Url
(
'entity.facetapi_facet.canonical'
,
array
(
'facetapi_facet'
=>
$this
->
entity
->
id
()
,
'search_api_index'
=>
$this
->
entity
->
getSearchApiIndex
()
));
return
new
Url
(
'entity.facetapi_facet.canonical'
,
array
(
'facetapi_facet'
=>
$this
->
entity
->
id
()));
}
/**
...
...
@@ -43,7 +43,7 @@ class FacetDeleteConfirmForm extends EntityConfirmFormBase {
public
function
submitForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{
$this
->
entity
->
delete
();
drupal_set_message
(
$this
->
t
(
'The facet %name has been deleted.'
,
array
(
'%name'
=>
$this
->
entity
->
label
())));
$form_state
->
setRedirect
(
'
entity.search_api_index.facets'
,
array
(
'search_api_index'
=>
$this
->
entity
->
getSearchApiIndex
())
);
$form_state
->
setRedirect
(
'
facetapi.overview'
);
}
}
src/Form/FacetForm.php
View file @
285101ea
...
...
@@ -14,6 +14,7 @@ use Drupal\Core\Form\FormStateInterface;
use
Drupal\facetapi\FacetInterface
;
use
Drupal\facetapi\FacetApiException
;
use
Drupal\facetapi\Widget\WidgetPluginManager
;
use
Drupal\search_api
\
Entity\Index
;
use
Drupal\search_api
\
Form\SubFormState
;
use
Drupal\search_api
\
IndexInterface
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
...
...
@@ -116,10 +117,8 @@ class FacetForm extends EntityForm {
*
* @param \Drupal\facetapi\FacetInterface $facet
* The server that is being created or edited.
* @param \Drupal\search_api\IndexInterface $search_api_index
* The search index we're creating a facet for.
*/
public
function
buildEntityForm
(
array
&
$form
,
FormStateInterface
$form_state
,
FacetInterface
$facet
,
IndexInterface
$search_api_index
)
{
public
function
buildEntityForm
(
array
&
$form
,
FormStateInterface
$form_state
,
FacetInterface
$facet
)
{
$form
[
'name'
]
=
array
(
'#type'
=>
'textfield'
,
...
...
@@ -142,7 +141,7 @@ class FacetForm extends EntityForm {
$form
[
'field_identifier'
]
=
[
'#type'
=>
'select'
,
'#options'
=>
$this
->
getIndexedFields
(
$search_api_index
),
'#options'
=>
$this
->
getIndexedFields
(),
'#title'
=>
$this
->
t
(
'Facet field'
),
'#description'
=>
$this
->
t
(
'Choose the indexed field.'
),
'#required'
=>
TRUE
,
...
...
@@ -205,15 +204,18 @@ class FacetForm extends EntityForm {
* @return array
* An array of all indexed fields.
*/
protected
function
getIndexedFields
(
IndexInterface
$search_api_index
)
{
protected
function
getIndexedFields
()
{
$indexed_fields
=
[];
$search_api_indexes
=
Index
::
loadMultiple
();
foreach
(
$search_api_indexes
as
$search_api_index
){
foreach
(
$search_api_index
->
getDatasources
()
as
$datasource_id
=>
$datasource
)
{
$fields
=
$search_api_index
->
getFieldsByDatasource
(
$datasource_id
);
foreach
(
$fields
as
$field
)
{
$indexed_fields
[
$field
->
getFieldIdentifier
()]
=
$field
->
getLabel
();
}
}
}
return
$indexed_fields
;
}
...
...
@@ -295,7 +297,7 @@ class FacetForm extends EntityForm {
$facet
=
$this
->
getEntity
();
$facet
->
save
();
drupal_set_message
(
$this
->
t
(
'The facet was successfully saved.'
));
$form_state
->
setRedirect
(
'
entity.search_api_index.facets'
,
array
(
'search_api_index'
=>
$facet
->
getSearchApiIndex
())
);
$form_state
->
setRedirect
(
'
facetapi.overview'
);
}
catch
(
FacetApiException
$e
)
{
$form_state
->
setRebuild
();
...
...
src/Tests/IntegrationTest.php
View file @
285101ea
...
...
@@ -45,7 +45,7 @@ class IntegrationTest extends FacetWebTestBase {
}
protected
function
addFacet
()
{
$facet_overview
=
$this
->
urlGenerator
->
generateFromRoute
(
'
entity.search_api_index.facets
'
,
[
'search_api_index'
=>
'webtest_index'
]);
$facet_overview
=
$this
->
urlGenerator
->
generateFromRoute
(
'
facetapi.overview
'
,
[
'search_api_index'
=>
'webtest_index'
]);
$this
->
drupalGet
(
$facet_overview
);
$this
->
assertResponse
(
200
);
$this
->
assertText
(
$this
->
t
(
'There are no facets defined.'
));
...
...
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