Drupal 8  8.0.2
GroupwiseMax Class Reference
Inheritance diagram for GroupwiseMax:

Public Member Functions

 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 submitOptionsForm (&$form, FormStateInterface $form_state)
 
 query ()
 
- Public Member Functions inherited from RelationshipPluginBase
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 usesGroupBy ()
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 query ()
 
 calculateDependencies ()
 
- Public Member Functions inherited from HandlerBase
 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 adminLabel ($short=FALSE)
 
 getField ($field=NULL)
 
 sanitizeValue ($value, $type=NULL)
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 setModuleHandler (ModuleHandlerInterface $module_handler)
 
 usesGroupBy ()
 
 buildGroupByForm (&$form, FormStateInterface $form_state)
 
 submitGroupByForm (&$form, FormStateInterface $form_state)
 
 hasExtraOptions ()
 
 defineExtraOptions (&$option)
 
 buildExtraOptionsForm (&$form, FormStateInterface $form_state)
 
 validateExtraOptionsForm ($form, FormStateInterface $form_state)
 
 submitExtraOptionsForm ($form, FormStateInterface $form_state)
 
 canExpose ()
 
 defaultExposeOptions ()
 
 exposedInfo ()
 
 buildExposedForm (&$form, FormStateInterface $form_state)
 
 validateExposed (&$form, FormStateInterface $form_state)
 
 submitExposed (&$form, FormStateInterface $form_state)
 
 buildExposeForm (&$form, FormStateInterface $form_state)
 
 validateExposeForm ($form, FormStateInterface $form_state)
 
 submitExposeForm ($form, FormStateInterface $form_state)
 
 showExposeButton (&$form, FormStateInterface $form_state)
 
 showExposeForm (&$form, FormStateInterface $form_state)
 
 access (AccountInterface $account)
 
 preQuery ()
 
 query ()
 
 postExecute (&$values)
 
 setRelationship ()
 
 ensureMyTable ()
 
 adminSummary ()
 
 isExposed ()
 
 isAGroup ()
 
 multipleExposedInput ()
 
 acceptExposedInput ($input)
 
 storeExposedInput ($input, $status)
 
 getJoin ()
 
 validate ()
 
 broken ()
 
 getDateFormat ($format)
 
 getDateField ()
 
 setViewsData (ViewsData $views_data)
 
 getEntityType ()
 
 displayExposedForm ($form, FormStateInterface $form_state)
 
 submitTemporaryForm ($form, FormStateInterface $form_state)
 
- Public Member Functions inherited from PluginBase
 __construct (array $configuration, $plugin_id, $plugin_definition)
 
 init (ViewExecutable $view, DisplayPluginBase $display, array &$options=NULL)
 
 filterByDefinedOptions (array &$storage)
 
 unpackOptions (&$storage, $options, $definition=NULL, $all=TRUE, $check=TRUE)
 
 destroy ()
 
 buildOptionsForm (&$form, FormStateInterface $form_state)
 
 validateOptionsForm (&$form, FormStateInterface $form_state)
 
 submitOptionsForm (&$form, FormStateInterface $form_state)
 
 query ()
 
 themeFunctions ()
 
 validate ()
 
 summaryTitle ()
 
 pluginTitle ()
 
 usesOptions ()
 
 globalTokenReplace ($string= '', array $options=array())
 
 getAvailableGlobalTokens ($prepared=FALSE, array $types=array())
 
 globalTokenForm (&$form, FormStateInterface $form_state)
 
 calculateDependencies ()
 
 getProvider ()
 
- Public Member Functions inherited from PluginInspectionInterface
 getPluginId ()
 
 getPluginDefinition ()
 
- Public Member Functions inherited from DerivativeInspectionInterface
 getBaseId ()
 
 getDerivativeId ()
 

Protected Member Functions

 defineOptions ()
 
 getTemporaryView ()
 
 leftQuery ($options)
 
 alterSubqueryCondition (AlterableInterface $query, &$conditions)
 
 conditionNamespace ($string)
 
- Protected Member Functions inherited from RelationshipPluginBase
 defineOptions ()
 
- Protected Member Functions inherited from HandlerBase
 defineOptions ()
 
 caseTransform ($string, $option)
 
 getModuleHandler ()
 
 placeholder ()
 
 getViewsData ()
 
- Protected Member Functions inherited from PluginBase
 defineOptions ()
 
 setOptionDefaults (array &$storage, array $options)
 
 doFilterByDefinedOptions (array &$storage, array $options)
 
 viewsTokenReplace ($text, $tokens)
 
 listLanguages ($flags=LanguageInterface::STATE_ALL, array $current_values=NULL)
 
 getRenderer ()
 

Additional Inherited Members

- Static Public Member Functions inherited from HandlerBase
static getTableJoin ($table, $base_table)
 
static breakString ($str, $force_int=FALSE)
 
- Static Public Member Functions inherited from PluginBase
static create (ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition)
 
static preRenderAddFieldsetMarkup (array $form)
 
static preRenderFlattenData ($form)
 
static queryLanguageSubstitutions ()
 
- Data Fields inherited from RelationshipPluginBase
 $alias
 
- Data Fields inherited from HandlerBase
 $query = NULL
 
 $table
 
 $tableAlias
 
 $actualTable
 
 $realField
 
 $field
 
 $actualField
 
 $relationship = NULL
 
- Data Fields inherited from PluginBase
const INCLUDE_NEGOTIATED = 16
 
const INCLUDE_ENTITY = 32
 
const VIEWS_QUERY_LANGUAGE_SITE_DEFAULT = '***LANGUAGE_site_default***'
 
 $options = array()
 
 $view = NULL
 
 $displayHandler
 
 $definition
 
- Protected Attributes inherited from HandlerBase
 $moduleHandler
 
 $viewsData
 
- Protected Attributes inherited from PluginBase
 $usesOptions = FALSE
 
 $renderer
 

Detailed Description

Relationship handler that allows a groupwise maximum of the linked in table. For a definition, see: http://dev.mysql.com/doc/refman/5.0/en/example-maximum-column-group-row.html In lay terms, instead of joining to get all matching records in the linked table, we get only one record, a 'representative record' picked according to a given criteria.

Example: Suppose we have a term view that gives us the terms: Horse, Cat, Aardvark. We wish to show for each term the most recent node of that term. What we want is some kind of relationship from term to node. But a regular relationship will give us all the nodes for each term, giving the view multiple rows per term. What we want is just one representative node per term, the node that is the 'best' in some way: eg, the most recent, the most commented on, the first in alphabetical order.

This handler gives us that kind of relationship from term to node. The method of choosing the 'best' implemented with a sort that the user selects in the relationship settings.

So if we want our term view to show the most commented node for each term, add the relationship and in its options, pick the 'Comment count' sort.

Relationship definition

  • 'outer field': The outer field to substitute into the correlated subquery. This must be the full field name, not the alias. Eg: 'term_data.tid'.
  • 'argument table', 'argument field': These options define a views argument that the subquery must add to itself to filter by the main view. Example: the main view shows terms, this handler is being used to get to the nodes base table. Your argument must be 'term_node', 'tid', as this is the argument that should be added to a node view to filter on terms.

A note on performance: This relationship uses a correlated subquery, which is expensive. Subsequent versions of this handler could also implement the alternative way of doing this, with a join – though this looks like it could be pretty messy to implement. This is also an expensive method, so providing both methods and allowing the user to choose which one works fastest for their data might be the best way. If your use of this relationship handler is likely to result in large data sets, you might want to consider storing statistics in a separate table, in the same way as node_comment_statistics.

("groupwise_max")

Member Function Documentation

alterSubqueryCondition ( AlterableInterface  $query,
$conditions 
)
protected

Recursive helper to add a namespace to conditions.

Similar to _views_query_tag_alter_condition().

(Though why is the condition we get in a simple query 3 levels deep???)

References GroupwiseMax\conditionNamespace().

Referenced by GroupwiseMax\leftQuery().

Here is the call graph for this function:

Here is the caller graph for this function:

buildOptionsForm ( $form,
FormStateInterface  $form_state 
)

{Provide a form to edit options for this plugin.}

Implements ViewsPluginInterface.

References Views\getAllViews(), t(), Views\viewsData(), and Views\viewsDataHelper().

Here is the call graph for this function:

conditionNamespace (   $string)
protected

Helper function to namespace query pieces.

Turns 'foo.bar' into '"foo_NAMESPACE".bar'. PostgreSQL doesn't support mixed-cased identifiers unless quoted, so we need to quote each single part to prevent from query exceptions.

Referenced by GroupwiseMax\alterSubqueryCondition(), and GroupwiseMax\leftQuery().

Here is the caller graph for this function:

defineOptions ( )
protected

{}

getTemporaryView ( )
protected

Helper function to create a pseudo view.

We use this to obtain our subquery SQL.

Referenced by GroupwiseMax\leftQuery().

Here is the caller graph for this function:

leftQuery (   $options)
protected

Generate a subquery given the user options, as set in the options.

These are passed in rather than picked up from the object because we generate the subquery when the options are saved, rather than when the view is run. This saves considerable time.

Parameters
$optionsAn array of options:
  • subquery_sort: the id of a views sort.
  • subquery_order: either ASC or DESC.
Returns
string The subquery SQL string, ready for use in the main query.

References GroupwiseMax\alterSubqueryCondition(), GroupwiseMax\conditionNamespace(), GroupwiseMax\getTemporaryView(), and Views\getView().

Referenced by GroupwiseMax\query().

Here is the call graph for this function:

Here is the caller graph for this function:

query ( )

{Add anything to the query that we might need to.}

Implements ViewsPluginInterface.

References Drupal\cache(), HandlerBase\ensureMyTable(), GroupwiseMax\leftQuery(), Views\pluginManager(), and Views\viewsData().

Here is the call graph for this function:

submitOptionsForm ( $form,
FormStateInterface  $form_state 
)

When the form is submitted, make sure to clear the subquery string cache.

Implements ViewsPluginInterface.

References Drupal\cache().

Here is the call graph for this function:


The documentation for this class was generated from the following file: