Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
facets
Commits
3b0da91b
Commit
3b0da91b
authored
Nov 07, 2015
by
Joris Vercammen
Browse files
Apply all fixes suggested by coder module
parent
7be5fc3b
Changes
57
Hide whitespace changes
Inline
Side-by-side
css/facetapi.admin.css
View file @
3b0da91b
...
...
@@ -14,10 +14,10 @@
}
#facetapi-groups-list
tr
.facet-source
{
border-top
:
1px
solid
#
E6E4DF
;
border-top
:
1px
solid
#
e6e4df
;
}
#facetapi-groups-list
tr
.facet
:last-of-type
{
border-bottom
:
1px
solid
#
E6E4DF
;
border-bottom
:
1px
solid
#
e6e4df
;
}
#facetapi-groups-list
tr
.facet-source
.facetapi-type
,
...
...
@@ -33,6 +33,6 @@
* Facet API Display page
*/
#edit-processors
.facetapi-processor-settings
{
margin-left
:
20px
;
margin-bottom
:
25px
;
}
\ No newline at end of file
margin-left
:
20px
;
margin-bottom
:
25px
;
}
facetapi.api.php
View file @
3b0da91b
...
...
@@ -10,7 +10,7 @@
*/
/**
* Alter the Facet API Query Type mapping
* Alter the Facet API Query Type mapping
.
*
* Modules may implement this hook to alter the mapping that defines how a
* certain data type should be handled in Search API based Facets.
...
...
@@ -25,4 +25,3 @@ function hook_facetapi_search_api_query_type_mapping_alter($backend_plugin_id, a
$query_types
[
'string'
]
=
'search_api_solr_string'
;
}
}
src/Annotation/FacetApiEmptyBehavior.php
View file @
3b0da91b
...
...
@@ -46,4 +46,4 @@ class FacetApiEmptyBehavior extends Plugin {
*/
public
$description
;
}
\ No newline at end of file
}
src/Annotation/FacetApiProcessor.php
View file @
3b0da91b
...
...
@@ -21,14 +21,14 @@ use Drupal\Component\Annotation\Plugin;
class
FacetApiProcessor
extends
Plugin
{
/**
* The processor plugin id
* The processor plugin id
.
*
* @var string
*/
public
$id
;
/**
* The human-readable name of the processor plugin
* The human-readable name of the processor plugin
.
*
* @ingroup plugin_translatable
*
...
...
src/Annotation/FacetApiQueryType.php
View file @
3b0da91b
...
...
@@ -22,14 +22,14 @@ use Drupal\Component\Annotation\Plugin;
class
FacetApiQueryType
extends
Plugin
{
/**
* The query type plugin id
* The query type plugin id
.
*
* @var string
*/
public
$id
;
/**
* The human-readable name of the query type plugin
* The human-readable name of the query type plugin
.
*
* @ingroup plugin_translatable
*
...
...
src/Annotation/FacetApiUrlProcessor.php
View file @
3b0da91b
...
...
@@ -21,14 +21,14 @@ use Drupal\Component\Annotation\Plugin;
class
FacetApiUrlProcessor
extends
Plugin
{
/**
* The facet_manager plugin id
* The facet_manager plugin id
.
*
* @var string
*/
public
$id
;
/**
* The human-readable name of the url processor plugin
* The human-readable name of the url processor plugin
.
*
* @ingroup plugin_translatable
*
...
...
@@ -52,4 +52,4 @@ class FacetApiUrlProcessor extends Plugin {
*/
public
$derivative
=
''
;
}
\ No newline at end of file
}
src/Annotation/FacetApiWidget.php
View file @
3b0da91b
...
...
@@ -22,14 +22,14 @@ use Drupal\Component\Annotation\Plugin;
class
FacetApiWidget
extends
Plugin
{
/**
* The widget plugin id
* The widget plugin id
.
*
* @var string
*/
public
$id
;
/**
* The human-readable name of the widget plugin
* The human-readable name of the widget plugin
.
*
* @ingroup plugin_translatable
*
...
...
src/ContextProvider/FacetContextProvider.php
View file @
3b0da91b
...
...
@@ -12,7 +12,9 @@ use Drupal\Core\Plugin\Context\Context;
use
Drupal\Core\Plugin\Context\ContextDefinition
;
use
Drupal\Core\Plugin\Context\ContextProviderInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
/**
*
*/
class
FacetContextProvider
implements
ContextProviderInterface
{
use
StringTranslationTrait
;
...
...
@@ -62,5 +64,4 @@ class FacetContextProvider implements ContextProviderInterface {
return
$contexts
;
}
}
src/EmptyBehavior/EmptyBehaviorInterface.php
View file @
3b0da91b
...
...
@@ -2,7 +2,7 @@
/**
* @file
* Contains Drupal\facetap\EmptyBehavior\EmptyBehaviorInterface
* Contains Drupal\facetap\EmptyBehavior\EmptyBehaviorInterface
.
*/
namespace
Drupal\facetapi\EmptyBehavior
;
...
...
src/EmptyBehavior/EmptyBehaviorPluginBase.php
View file @
3b0da91b
<?php
/**
* Contains \Drupal\facetapi\EmptyBehavior\EmptyBehaviorPluginBase
* @file
* Contains \Drupal\facetapi\EmptyBehavior\EmptyBehaviorPluginBase.
*/
namespace
Drupal\facetapi\EmptyBehavior
;
...
...
@@ -65,7 +66,7 @@ abstract class EmptyBehaviorPluginBase extends PluginBase implements EmptyBehavi
* {@inheritdoc}
*/
public
function
buildConfigurationForm
(
array
$form
,
FormStateInterface
$form_state
)
{
return
false
;
return
FALSE
;
}
/**
...
...
@@ -77,4 +78,5 @@ abstract class EmptyBehaviorPluginBase extends PluginBase implements EmptyBehavi
* {@inheritdoc}
*/
public
function
submitConfigurationForm
(
array
&
$form
,
FormStateInterface
$form_state
)
{}
}
\ No newline at end of file
}
src/EmptyBehavior/EmptyBehaviorPluginManager.php
View file @
3b0da91b
<?php
/**
* Contains \Drupal\facetapi\EmptyBehavior\EmptyBehaviorPluginManager
* @file
* Contains \Drupal\facetapi\EmptyBehavior\EmptyBehaviorPluginManager.
*/
namespace
Drupal\facetapi\EmptyBehavior
;
...
...
@@ -17,7 +18,11 @@ use Drupal\Core\Plugin\DefaultPluginManager;
* @see \Drupal\facetapi\EmptyBehavior\EmptyBehaviorInterface
*/
class
EmptyBehaviorPluginManager
extends
DefaultPluginManager
{
/**
*
*/
public
function
__construct
(
\
Traversable
$namespaces
,
CacheBackendInterface
$cache_backend
,
ModuleHandlerInterface
$module_handler
)
{
parent
::
__construct
(
'Plugin/facetapi/empty_behavior'
,
$namespaces
,
$module_handler
,
'Drupal\facetapi\EmptyBehavior\EmptyBehaviorInterface'
,
'Drupal\facetapi\Annotation\FacetApiEmptyBehavior'
);
}
}
\ No newline at end of file
}
src/Entity/Facet.php
View file @
3b0da91b
...
...
@@ -9,7 +9,6 @@ namespace Drupal\facetapi\Entity;
use
Drupal\Core\Config\Entity\ConfigEntityBase
;
use
Drupal\facetapi\FacetInterface
;
use
Drupal\facetapi\Result\Result
;
/**
* Defines the search index configuration entity.
...
...
@@ -178,7 +177,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
protected
$only_visible_when_facet_source_is_visible
;
/**
* Widget Plugin Manager
* Widget Plugin Manager
.
*
* @var object
*/
...
...
@@ -306,33 +305,54 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return
$this
;
}
/**
*
*/
public
function
getFieldIdentifier
()
{
return
$this
->
field_identifier
;
}
/**
*
*/
public
function
setFieldIdentifier
(
$field_identifier
)
{
$this
->
field_identifier
=
$field_identifier
;
return
$this
;
}
/**
*
*/
public
function
getQueryTypes
()
{
return
$this
->
query_type_name
;
}
/**
*
*/
public
function
setFieldEmptyBehavior
(
$behavior_id
)
{
$this
->
empty_behavior
=
$behavior_id
;
return
$this
;
}
/**
*
*/
public
function
getFieldEmptyBehavior
()
{
return
$this
->
empty_behavior
;
}
/**
*
*/
public
function
getUrlProcessorName
()
{
// @Todo: for now if the url processor is not set, defualt to query_string.
return
isset
(
$this
->
url_processor_name
)
?
$this
->
url_processor_name
:
'query_string'
;
}
/**
*
*/
public
function
getName
()
{
return
$this
->
name
;
}
...
...
@@ -402,6 +422,9 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return
$parameters
;
}
/**
*
*/
public
function
getResults
()
{
return
$this
->
results
;
}
...
...
@@ -448,7 +471,7 @@ class Facet extends ConfigEntityBase implements FacetInterface {
/**
* {@inheritdoc}
*/
public
function
getFacetSources
(
$only_enabled
=
false
)
{
public
function
getFacetSources
(
$only_enabled
=
FALSE
)
{
if
(
!
isset
(
$this
->
facetSourcePlugins
))
{
$this
->
facetSourcePlugins
=
[];
...
...
@@ -478,10 +501,16 @@ class Facet extends ConfigEntityBase implements FacetInterface {
return
array_intersect_key
(
$this
->
facetSourcePlugins
,
array_flip
(
$this
->
facetSourcePlugins
));
}
/**
*
*/
public
function
setPath
(
$path
)
{
$this
->
path
=
$path
;
}
/**
*
*/
public
function
getPath
()
{
return
$this
->
path
;
}
...
...
src/Exception/Exception.php
View file @
3b0da91b
...
...
@@ -10,4 +10,4 @@ namespace Drupal\facetapi\Exception;
/**
* Represents an exception that occurred in some part of the Facet API.
*/
class
Exception
extends
\
Exception
{
}
class
Exception
extends
\
Exception
{}
src/Exception/InvalidProcessorException.php
View file @
3b0da91b
...
...
@@ -10,4 +10,4 @@ namespace Drupal\facetapi\Exception;
/**
* Represents an exception that occurred when calling an invalid processor.
*/
class
InvalidProcessorException
extends
\
Exception
{
}
class
InvalidProcessorException
extends
\
Exception
{}
src/Exception/InvalidQueryTypeException.php
View file @
3b0da91b
...
...
@@ -10,4 +10,4 @@ namespace Drupal\facetapi\Exception;
/**
* Represents an exception that occurred when calling an invalid query type.
*/
class
InvalidQueryTypeException
extends
\
Exception
{
}
class
InvalidQueryTypeException
extends
\
Exception
{}
src/FacetInterface.php
View file @
3b0da91b
<?php
/**
* @file
* Contains Drupal\facetapi\FacetInterface
* Contains Drupal\facetapi\FacetInterface
.
*/
namespace
Drupal\facetapi
;
use
Drupal\Core\Config\Entity\ConfigEntityInterface
;
use
Drupal\facetapi\FacetSource\FacetSourceInterface
;
use
Drupal\facetapi\Result\ResultInterface
;
/**
*
*/
interface
FacetInterface
extends
ConfigEntityInterface
{
/**
* Sets the facet's widget plugin id.
*
* @param string $widget
* @param string $widget
*
* @return $this
*/
public
function
setWidget
(
$widget
);
...
...
@@ -51,7 +52,7 @@ interface FacetInterface extends ConfigEntityInterface {
*/
public
function
getFieldEmptyBehavior
();
/**
/**
* Set field identifier.
*
* @return mixed
...
...
@@ -91,6 +92,7 @@ interface FacetInterface extends ConfigEntityInterface {
* Check if a value is active.
*
* @param string $value
*
* @return bool
*/
public
function
isActiveValue
(
$value
);
...
...
@@ -171,7 +173,8 @@ interface FacetInterface extends ConfigEntityInterface {
/**
* Gets the facet manager plugin id
* Gets the facet manager plugin id.
*
* @return string
*/
public
function
getManagerPluginId
();
...
...
@@ -182,12 +185,14 @@ interface FacetInterface extends ConfigEntityInterface {
* This is usually the name of the Search-api view.
*
* @param string $facet_source_id
*
* @return $this
*/
public
function
setFacetSourceId
(
$facet_source_id
);
/**
* Returns the Facet source id.
*
* @return string
*/
public
function
getFacetSourceId
();
...
...
@@ -204,6 +209,7 @@ interface FacetInterface extends ConfigEntityInterface {
* Load the facet sources for this facet.
*
* @param bool|TRUE $only_enabled
*
* @return FacetSourceInterface[]
*/
public
function
getFacetSources
(
$only_enabled
=
TRUE
);
...
...
@@ -226,6 +232,7 @@ interface FacetInterface extends ConfigEntityInterface {
* Returns an array of processors with their configuration.
*
* @param bool|TRUE $only_enabled
*
* @return \Drupal\facetapi\Processor\ProcessorInterface[]
*/
public
function
getProcessors
(
$only_enabled
=
TRUE
);
...
...
@@ -250,7 +257,7 @@ interface FacetInterface extends ConfigEntityInterface {
/**
* Sets the "only visible when facet source is visible" boolean flag.
*
* @param bool
ean
$only_visible_when_facet_source_is_visible
* @param bool $only_visible_when_facet_source_is_visible
* A boolean flag indicating if the facet should be hidden on a page that
* does not show the facet source.
*
...
...
@@ -264,4 +271,5 @@ interface FacetInterface extends ConfigEntityInterface {
* @return boolean
*/
public
function
getOnlyVisibleWhenFacetSourceIsVisible
();
}
src/FacetManager/DefaultFacetManager.php
View file @
3b0da91b
...
...
@@ -13,7 +13,6 @@ use Drupal\Core\StringTranslation\StringTranslationTrait;
use
Drupal\facetapi\EmptyBehavior\EmptyBehaviorPluginManager
;
use
Drupal\facetapi\Exception\InvalidProcessorException
;
use
Drupal\facetapi\FacetInterface
;
use
Drupal\facetapi\FacetSource\FacetSourceInterface
;
use
Drupal\facetapi\FacetSource\FacetSourcePluginManager
;
use
Drupal\facetapi\Processor\BuildProcessorInterface
;
use
Drupal\facetapi\Processor\PreQueryProcessorInterface
;
...
...
@@ -21,7 +20,6 @@ use Drupal\facetapi\Processor\ProcessorInterface;
use
Drupal\facetapi\Processor\ProcessorPluginManager
;
use
Drupal\facetapi\QueryType\QueryTypePluginManager
;
use
Drupal\facetapi\Widget\WidgetPluginManager
;
use
\
Drupal\facetapi\Entity\Facet
;
/**
* Base class for Facet API FacetManagers.
...
...
@@ -303,7 +301,7 @@ class DefaultFacetManager {
// enough to halt all further processing. This should probably go in an
// earlier step of the facet building process but here's fine for now.
$facet_source
=
$facet
->
getFacetSource
();
if
(
!
$facet_source
->
isRenderedInCurrentRequest
()){
if
(
!
$facet_source
->
isRenderedInCurrentRequest
())
{
return
[];
}
}
...
...
@@ -321,9 +319,8 @@ class DefaultFacetManager {
// Get the current results from the facets and let all processors that
// trigger on the build step do their build processing.
// @see \Drupal\facetapi\Processor\BuildProcessorInterface
// @see \Drupal\facetapi\Processor\WidgetOrderProcessorInterface
// @see \Drupal\facetapi\Processor\BuildProcessorInterface.
// @see \Drupal\facetapi\Processor\WidgetOrderProcessorInterface.
$results
=
$facet
->
getResults
();
foreach
(
$facet
->
getProcessors
()
as
$processor
)
{
...
...
@@ -339,7 +336,6 @@ class DefaultFacetManager {
}
$facet
->
setResults
(
$results
);
// Returns the render array, this render array contains the empty behaviour
// if no results are found. If there are results we're going to initialize
// the widget from the widget plugin manager and return it's build method.
...
...
@@ -375,4 +371,5 @@ class DefaultFacetManager {
$facet
->
setPath
(
$facet_source_plugin
->
getPath
());
}
}
}
src/FacetSource/FacetSourceDeriverBase.php
View file @
3b0da91b
...
...
@@ -12,8 +12,10 @@ use Drupal\Core\Entity\EntityTypeManager;
use
Drupal\Core\Plugin\Discovery\ContainerDeriverInterface
;
use
Drupal\Core\StringTranslation\StringTranslationTrait
;
use
Symfony\Component\DependencyInjection\ContainerInterface
;
abstract
class
FacetSourceDeriverBase
implements
ContainerDeriverInterface
{
/**
*
*/
abstract
class
FacetSourceDeriverBase
implements
ContainerDeriverInterface
{
use
StringTranslationTrait
;
...
...
@@ -96,4 +98,5 @@ abstract class FacetSourceDeriverBase implements ContainerDeriverInterface {
public
function
compareDerivatives
(
array
$a
,
array
$b
)
{
return
strnatcasecmp
(
$a
[
'label'
],
$b
[
'label'
]);
}
}
src/FacetSource/FacetSourceInterface.php
View file @
3b0da91b
...
...
@@ -16,6 +16,7 @@ use Drupal\facetapi\FacetInterface;
* A facet source is used to abstract the data source where facets can be added
* to. A good example of this is a search api view. There are other possible
* facet data sources, these all implement the FacetSourceInterface.
*
* @see plugin_api
*/
interface
FacetSourceInterface
{
...
...
@@ -34,6 +35,7 @@ interface FacetSourceInterface {
* Fill in facet data in to the configured facets.
*
* @param \Drupal\facetapi\FacetInterface[] $facets
*
* @return mixed
*/
public
function
fillFacetsWithResults
(
$facets
);
...
...
@@ -49,6 +51,7 @@ interface FacetSourceInterface {
* Get the allowed query types for a given facet for the facet source.
*
* @param \Drupal\facetapi\FacetInterface $facet
*
* @return array of allowed query types
*
* @throws \Drupal\facetapi\Exception\Exception
...
...
@@ -67,7 +70,6 @@ interface FacetSourceInterface {
public
function
isRenderedInCurrentRequest
();
/**
*
* Returns an array of fields that are defined on the datasource.
*
* This returns an array of fields that are defined on the source. This array
...
...
src/Form/FacetDeleteConfirmForm.php
View file @
3b0da91b
...
...
@@ -78,7 +78,7 @@ class FacetDeleteConfirmForm extends EntityConfirmFormBase {
*/
protected
function
isFacetUsedBlock
()
{
//
i
f the block module is not installed, we should automatically return
//
I
f the block module is not installed, we should automatically return
// false and go ahead with deletion.
if
(
!
\
Drupal
::
moduleHandler
()
->
moduleExists
(
'block'
))
{
return
FALSE
;
...
...
Prev
1
2
3
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new 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