class ExtendedSql in Views Contextual Filters OR 8
Object used to create a SELECT query.
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\views\Plugin\views\query\QueryPluginBase implements CacheableDependencyInterface
- class \Drupal\views\Plugin\views\query\Sql
- class \Drupal\views_contextual_filters_or\Plugin\views\query\ExtendedSql
- class \Drupal\views\Plugin\views\query\Sql
- class \Drupal\views\Plugin\views\query\QueryPluginBase implements CacheableDependencyInterface
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of ExtendedSql
File
- src/
Plugin/ views/ query/ ExtendedSql.php, line 11
Namespace
Drupal\views_contextual_filters_or\Plugin\views\queryView source
class ExtendedSql extends Sql {
protected function defineOptions() {
$options = parent::defineOptions();
$options['contextual_filters_or'] = array(
'default' => FALSE,
);
return $options;
}
/**
* Add settings for the ui.
*/
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['contextual_filters_or'] = array(
'#title' => t('Contextual filters OR'),
'#description' => t('Contextual filters applied to OR logic.'),
'#type' => 'checkbox',
'#default_value' => !empty($this->options['contextual_filters_or']),
);
}
/**
* Add a simple WHERE clause to the query. The caller is responsible for
* ensuring that all fields are fully qualified (TABLE.FIELD) and that
* the table already exists in the query.
*
* The $field, $value and $operator arguments can also be passed in with a
* single DatabaseCondition object, like this:
* @code
* $this->query->addWhere(
* $this->options['group'],
* db_or()
* ->condition($field, $value, 'NOT IN')
* ->condition($field, $value, 'IS NULL')
* );
* @endcode
*
* @param $group
* The WHERE group to add these to; groups are used to create AND/OR
* sections. Groups cannot be nested. Use 0 as the default group.
* If the group does not yet exist it will be created as an AND group.
* @param $field
* The name of the field to check.
* @param $value
* The value to test the field against. In most cases, this is a scalar. For more
* complex options, it is an array. The meaning of each element in the array is
* dependent on the $operator.
* @param $operator
* The comparison operator, such as =, <, or >=. It also accepts more
* complex options such as IN, LIKE, LIKE BINARY, or BETWEEN. Defaults to =.
* If $field is a string you have to use 'formula' here.
*
* @see \Drupal\Core\Database\Query\ConditionInterface::condition()
* @see \Drupal\Core\Database\Query\Condition
*/
public function addWhere($group, $field, $value = NULL, $operator = NULL) {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
$group = 0;
}
// Check for a group.
if (!isset($this->where[$group])) {
$op = $this->options['contextual_filters_or'] ? 'OR' : 'AND';
$this
->setWhereGroup($op, $group);
}
$this->where[$group]['conditions'][] = array(
'field' => $field,
'value' => $value,
'operator' => $operator,
);
}
/**
* Add a complex WHERE clause to the query.
*
* The caller is responsible for ensuring that all fields are fully qualified
* (TABLE.FIELD) and that the table already exists in the query.
* Internally the dbtng method "where" is used.
*
* @param $group
* The WHERE group to add these to; groups are used to create AND/OR
* sections. Groups cannot be nested. Use 0 as the default group.
* If the group does not yet exist it will be created as an AND group.
* @param $snippet
* The snippet to check. This can be either a column or
* a complex expression like "UPPER(table.field) = 'value'"
* @param $args
* An associative array of arguments.
*
* @see QueryConditionInterface::where()
*/
public function addWhereExpression($group, $snippet, $args = array()) {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
$group = 0;
}
// Check for a group.
if (!isset($this->where[$group])) {
$op = $this->options['contextual_filters_or'] ? 'OR' : 'AND';
$this
->setWhereGroup($op, $group);
}
$this->where[$group]['conditions'][] = array(
'field' => $snippet,
'value' => $args,
'operator' => 'formula',
);
}
/**
* Add a complex HAVING clause to the query.
* The caller is responsible for ensuring that all fields are fully qualified
* (TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query.
* Internally the dbtng method "having" is used.
*
* @param $group
* The HAVING group to add these to; groups are used to create AND/OR
* sections. Groups cannot be nested. Use 0 as the default group.
* If the group does not yet exist it will be created as an AND group.
* @param $snippet
* The snippet to check. This can be either a column or
* a complex expression like "COUNT(table.field) > 3"
* @param $args
* An associative array of arguments.
*
* @see QueryConditionInterface::having()
*/
public function addHavingExpression($group, $snippet, $args = array()) {
// Ensure all variants of 0 are actually 0. Thus '', 0 and NULL are all
// the default group.
if (empty($group)) {
$group = 0;
}
// Check for a group.
if (!isset($this->having[$group])) {
$op = $this->options['contextual_filters_or'] ? 'OR' : 'AND';
$this
->setWhereGroup($op, $group, 'having');
}
// Add the clause and the args.
$this->having[$group]['conditions'][] = array(
'field' => $snippet,
'value' => $args,
'operator' => 'formula',
);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
DependencySerializationTrait:: |
protected | property | An array of entity type IDs keyed by the property name of their storages. | |
DependencySerializationTrait:: |
protected | property | An array of service IDs keyed by property name used for serialization. | |
DependencySerializationTrait:: |
public | function | 1 | |
DependencySerializationTrait:: |
public | function | 2 | |
ExtendedSql:: |
public | function |
Add a complex HAVING clause to the query.
The caller is responsible for ensuring that all fields are fully qualified
(TABLE.FIELD) and that the table and an appropriate GROUP BY already exist in the query.
Internally the dbtng method… Overrides Sql:: |
|
ExtendedSql:: |
public | function |
Add a simple WHERE clause to the query. The caller is responsible for
ensuring that all fields are fully qualified (TABLE.FIELD) and that
the table already exists in the query. Overrides Sql:: |
|
ExtendedSql:: |
public | function |
Add a complex WHERE clause to the query. Overrides Sql:: |
|
ExtendedSql:: |
public | function |
Add settings for the ui. Overrides Sql:: |
|
ExtendedSql:: |
protected | function |
Information about options for all kinds of purposes will be held here. Overrides Sql:: |
|
MessengerTrait:: |
public | function | Gets the messenger. | 29 |
MessengerTrait:: |
public | function | Sets the messenger. | |
PluginBase:: |
protected | property | Configuration information passed into the plugin. | 1 |
PluginBase:: |
public | property | Plugins's definition | |
PluginBase:: |
public | property | The display object this plugin is for. | |
PluginBase:: |
public | property | Options for this plugin will be held here. | |
PluginBase:: |
protected | property | The plugin implementation definition. | 1 |
PluginBase:: |
protected | property | The plugin_id. | |
PluginBase:: |
protected | property | Stores the render API renderer. | 3 |
PluginBase:: |
protected | property | Denotes whether the plugin has an additional options form. | 8 |
PluginBase:: |
public | property | The top object of a view. | 1 |
PluginBase:: |
constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
PluginBase:: |
public | function |
Clears a plugin. Overrides ViewsPluginInterface:: |
2 |
PluginBase:: |
protected | function | Do the work to filter out stored options depending on the defined options. | |
PluginBase:: |
public | function |
Filter out stored options depending on the defined options. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns an array of available token replacements. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: |
|
PluginBase:: |
public | function |
Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: |
3 |
PluginBase:: |
public | function |
Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: |
|
PluginBase:: |
public | function |
Returns the plugin provider. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
protected | function | Returns the render API renderer. | 1 |
PluginBase:: |
public | function |
Adds elements for available core tokens to a form. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns a string with any core tokens replaced. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
constant | Include entity row languages when listing languages. | ||
PluginBase:: |
constant | Include negotiated languages when listing languages. | ||
PluginBase:: |
public | function | Determines if the plugin is configurable. | |
PluginBase:: |
protected | function | Makes an array of languages, optionally including special languages. | |
PluginBase:: |
public | function |
Return the human readable name of the display. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function |
Moves form elements into fieldsets for presentation purposes. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function |
Flattens the structure of form elements. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public static | function | Returns substitutions for Views queries for languages. | |
PluginBase:: |
protected | function | Fills up the options of the plugin with defaults. | |
PluginBase:: |
public | function |
Provide a full list of possible theme templates used by this style. Overrides ViewsPluginInterface:: |
1 |
PluginBase:: |
public static | function |
Lists the trusted callbacks provided by the implementing class. Overrides TrustedCallbackInterface:: |
6 |
PluginBase:: |
public | function |
Unpack options over our existing defaults, drilling down into arrays
so that defaults don't get totally blown away. Overrides ViewsPluginInterface:: |
|
PluginBase:: |
public | function |
Returns the usesOptions property. Overrides ViewsPluginInterface:: |
8 |
PluginBase:: |
public | function |
Validate that the plugin is correct and can be saved. Overrides ViewsPluginInterface:: |
6 |
PluginBase:: |
protected | function | Replaces Views' tokens in a given string. The resulting string will be sanitized with Xss::filterAdmin. | 1 |
PluginBase:: |
constant | Query string to indicate the site default language. | ||
QueryPluginBase:: |
protected | property | Stores the limit of items that should be requested in the query. | |
QueryPluginBase:: |
public | property | A pager plugin that should be provided by the display. | |
QueryPluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides PluginBase:: |
1 |
QueryPluginBase:: |
public | function |
The cache contexts associated with this object. Overrides CacheableDependencyInterface:: |
|
QueryPluginBase:: |
public | function | Returns an array of all tables from the query that map to an entity type. | |
QueryPluginBase:: |
public | function | Returns the limit of the query. | |
QueryPluginBase:: |
public | function | Get the timezone offset in seconds. | |
QueryPluginBase:: |
public | function | Control how all WHERE and HAVING groups are put together. | |
QueryPluginBase:: |
public | function | Set a LIMIT on the query, specifying a maximum number of results. | |
QueryPluginBase:: |
public | function | Set an OFFSET on the query, specifying a number of results to skip | |
QueryPluginBase:: |
public | function | Create a new grouping for the WHERE or HAVING clause. | |
QueryPluginBase:: |
public | function |
Returns the summary of the settings in the display. Overrides PluginBase:: |
|
QueryPluginBase:: |
public | function |
Validate the options form. Overrides PluginBase:: |
|
Sql:: |
protected | property | The database-specific date handler. | |
Sql:: |
public | property | A flag as to whether or not to make the primary field distinct. | |
Sql:: |
protected | property | The entity type manager. | |
Sql:: |
protected | property | An array mapping table aliases and field names to field aliases. | |
Sql:: |
public | property | An array of fields. | |
Sql:: |
protected | property | Should this query be optimized for counts, for example no sorts. | |
Sql:: |
public | property | A simple array of group by clauses. | |
Sql:: |
protected | property | The default operator to use when connecting the WHERE groups. May be AND or OR. | |
Sql:: |
protected | property | ||
Sql:: |
public | property | An array of sections of the HAVING query. Each section is in itself an array of pieces and a flag as to whether or not it should be AND or OR. | |
Sql:: |
protected | property |
The messenger. Overrides MessengerTrait:: |
|
Sql:: |
protected | property | Is the view marked as not distinct. | |
Sql:: |
public | property | A simple array of order by clauses. | |
Sql:: |
public | property | Holds an array of relationships, which are aliases of the primary table that represent different ways to join the same table in. | |
Sql:: |
protected | property | A list of tables in the order they should be added, keyed by alias. | |
Sql:: |
public | property | Holds an array of tables and counts added so that we can create aliases | |
Sql:: |
public | property | Query tags which will be passed over to the dbtng query object. | |
Sql:: |
public | property | An array of sections of the WHERE query. Each section is in itself an array of pieces and a flag as to whether or not it should be AND or OR. | |
Sql:: |
public | function | Add a field to the query table, possibly with an alias. This will automatically call ensureTable to make sure the required table exists, *unless* $table is unset. | |
Sql:: |
public | function | Add a simple GROUP BY clause to the query. The caller is responsible for ensuring that the fields are fully qualified and the table is properly added. | |
Sql:: |
public | function | Add an ORDER BY clause to the query. | |
Sql:: |
public | function | A relationship is an alternative endpoint to a series of table joins. Relationships must be aliases of the primary table and they must join either to the primary table or to a pre-existing relationship. | |
Sql:: |
public | function |
Add a signature to the query, if such a thing is feasible. Overrides QueryPluginBase:: |
|
Sql:: |
public | function | Add a table to the query, ensuring the path exists. | |
Sql:: |
public | function | Adds a query tag to the sql object. | |
Sql:: |
protected | function | Fix a join to adhere to the proper relationship; the left table can vary based upon what relationship items are joined in on. | |
Sql:: |
public | function | ||
Sql:: |
public | function | ||
Sql:: |
public | function |
Let modules modify the query just prior to finalizing it. Overrides QueryPluginBase:: |
|
Sql:: |
protected | function | Sets entities onto the view result row objects. | |
Sql:: |
public | function |
Builds the necessary info to execute the query. Overrides QueryPluginBase:: |
|
Sql:: |
protected | function | Construct the "WHERE" or "HAVING" part of the query. | |
Sql:: |
public | function | Remove all fields that may've been added; primarily used for summary mode where we're changing the query because we didn't get data we needed. | |
Sql:: |
protected | function | Adds fields to the query. | |
Sql:: |
public static | function |
Creates an instance of the plugin. Overrides PluginBase:: |
|
Sql:: |
protected | function | Make sure that the specified table can be properly linked to the primary table in the JOINs. This function uses recursion. If the tables needed to complete the path back to the primary table are not in the query they will be added, but additional… | |
Sql:: |
public | function | Ensure a table exists in the queue; if it already exists it won't do anything, but if it doesn't it will add the table queue. It will ensure a path leads back to the relationship table. | |
Sql:: |
public | function |
Executes the query and fills the associated view object with according
values. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Get aggregation info for group by queries. Overrides QueryPluginBase:: |
|
Sql:: |
protected | function | Gets all the involved entities of the view. | |
Sql:: |
public | function |
The maximum age for which this object may be cached. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
The cache tags associated with this object. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Returns a Unix timestamp to database native timestamp expression. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Creates cross-database date formatting. Overrides QueryPluginBase:: |
|
Sql:: |
protected | function | Returns the alias for the given field added to $table. | |
Sql:: |
public | function | Retrieve join data from the larger join data cache. | |
Sql:: |
protected | function | Returns a list of non-aggregates to be added to the "group by" clause. | |
Sql:: |
public | function | Get the information associated with a table. | |
Sql:: |
public | function | Returns a reference to the table queue array for this query. | |
Sql:: |
public | function | Get the arguments attached to the WHERE and HAVING clauses of this query. | |
Sql:: |
public | function |
Initialize the plugin. Overrides PluginBase:: |
|
Sql:: |
public | function |
Loads all entities contained in the passed-in $results.
.
If the entity belongs to the base table, then it gets stored in
$result->_entity. Otherwise, it gets stored in
$result->_relationship_entities[$relationship_id]; Overrides QueryPluginBase:: |
|
Sql:: |
protected | function | ||
Sql:: |
public | function | Generates a unique placeholder used in the db query. | |
Sql:: |
public | function |
Generate a query and a countquery from all of the information supplied
to the object. Overrides QueryPluginBase:: |
|
Sql:: |
public | function | Add a table to the query without ensuring the path. | |
Sql:: |
public | function | Set what field the query will count() on for paging. | |
Sql:: |
protected | function | Set the view to be distinct (per base field). | |
Sql:: |
public | function |
Applies a timezone offset to the given field. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Set the database to the current user timezone. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Special submit handling. Overrides QueryPluginBase:: |
|
Sql:: |
public | function |
Constructs a Sql object. Overrides PluginBase:: |
|
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. | |
TrustedCallbackInterface:: |
constant | Untrusted callbacks throw exceptions. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger silenced E_USER_DEPRECATION errors. | ||
TrustedCallbackInterface:: |
constant | Untrusted callbacks trigger E_USER_WARNING errors. |