Chris@0: display_handler->options['pager']['type'] == 'none') { Chris@0: $messages[] = Drupal\views\Analyzer::formatMessage(t('This view has no pager. This could cause performance issues when the view contains many items.'), 'warning'); Chris@0: } Chris@0: Chris@0: return $messages; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Describe data tables and fields (or the equivalent) to Views. Chris@0: * Chris@0: * The table and fields are processed in Views using various plugins. See Chris@0: * the @link views_plugins Views plugins topic @endlink for more information. Chris@0: * Chris@0: * To provide views data for an entity, instead of implementing this hook, Chris@0: * create a class implementing \Drupal\views\EntityViewsDataInterface and Chris@0: * reference this in the "views" annotation in the entity class. The return Chris@0: * value of the getViewsData() method on the interface is the same as this hook, Chris@0: * and base class in \Drupal\views\EntityViewsData will take care of adding the Chris@0: * basic Views tables and fields for your entity. See the Chris@0: * @link entity_api Entity API topic @endlink for more information about Chris@0: * entities. Chris@0: * Chris@0: * The data described with this hook is fetched and retrieved by Chris@0: * \Drupal\views\Views::viewsData()->get(). Chris@0: * Chris@0: * @return array Chris@0: * An associative array describing the structure of database tables and fields Chris@0: * (and their equivalents) provided for use in Views. At the outermost level, Chris@0: * the keys are the names used internally by Views for the tables (usually the Chris@0: * actual table name). Each table's array describes the table itself, how to Chris@0: * join to other tables, and the fields that are part of the table. The sample Chris@0: * function body provides documentation of the details. Chris@0: * Chris@0: * @see hook_views_data_alter() Chris@0: */ Chris@0: function hook_views_data() { Chris@0: // This example describes how to write hook_views_data() for a table defined Chris@0: // like this: Chris@0: // CREATE TABLE example_table ( Chris@0: // nid INT(11) NOT NULL COMMENT 'Primary key: {node}.nid.', Chris@0: // plain_text_field VARCHAR(32) COMMENT 'Just a plain text field.', Chris@0: // numeric_field INT(11) COMMENT 'Just a numeric field.', Chris@0: // boolean_field INT(1) COMMENT 'Just an on/off field.', Chris@0: // timestamp_field INT(8) COMMENT 'Just a timestamp field.', Chris@0: // langcode VARCHAR(12) COMMENT 'Language code field.', Chris@0: // PRIMARY KEY(nid) Chris@0: // ); Chris@0: Chris@0: // Define the return array. Chris@0: $data = []; Chris@0: Chris@0: // The outermost keys of $data are Views table names, which should usually Chris@0: // be the same as the hook_schema() table names. Chris@0: $data['example_table'] = []; Chris@0: Chris@0: // The value corresponding to key 'table' gives properties of the table Chris@0: // itself. Chris@0: $data['example_table']['table'] = []; Chris@0: Chris@0: // Within 'table', the value of 'group' (translated string) is used as a Chris@0: // prefix in Views UI for this table's fields, filters, etc. When adding Chris@0: // a field, filter, etc. you can also filter by the group. Chris@0: $data['example_table']['table']['group'] = t('Example table'); Chris@0: Chris@0: // Within 'table', the value of 'provider' is the module that provides schema Chris@0: // or the entity type that causes the table to exist. Setting this ensures Chris@0: // that views have the correct dependencies. This is automatically set to the Chris@0: // module that implements hook_views_data(). Chris@0: $data['example_table']['table']['provider'] = 'example_module'; Chris@0: Chris@0: // Some tables are "base" tables, meaning that they can be the base tables Chris@0: // for views. Non-base tables can only be brought in via relationships in Chris@0: // views based on other tables. To define a table to be a base table, add Chris@0: // key 'base' to the 'table' array: Chris@0: $data['example_table']['table']['base'] = [ Chris@0: // Identifier (primary) field in this table for Views. Chris@0: 'field' => 'nid', Chris@0: // Label in the UI. Chris@0: 'title' => t('Example table'), Chris@0: // Longer description in the UI. Required. Chris@0: 'help' => t('Example table contains example content and can be related to nodes.'), Chris@0: 'weight' => -10, Chris@0: ]; Chris@0: Chris@0: // Some tables have an implicit, automatic relationship to other tables, Chris@0: // meaning that when the other table is available in a view (either as the Chris@0: // base table or through a relationship), this table's fields, filters, etc. Chris@0: // are automatically made available without having to add an additional Chris@0: // relationship. To define an implicit relationship that will make your Chris@0: // table automatically available when another table is present, add a 'join' Chris@0: // section to your 'table' section. Note that it is usually only a good idea Chris@0: // to do this for one-to-one joins, because otherwise your automatic join Chris@0: // will add more rows to the view. It is also not a good idea to do this if Chris@0: // most views won't need your table -- if that is the case, define a Chris@0: // relationship instead (see below). Chris@0: // Chris@0: // If you've decided an automatic join is a good idea, here's how to do it; Chris@0: // the resulting SQL query will look something like this: Chris@0: // ... FROM example_table et ... JOIN node_field_data nfd Chris@0: // ON et.nid = nfd.nid AND ('extra' clauses will be here) ... Chris@0: // although the table aliases will be different. Chris@0: $data['example_table']['table']['join'] = [ Chris@0: // Within the 'join' section, list one or more tables to automatically Chris@0: // join to. In this example, every time 'node_field_data' is available in Chris@0: // a view, 'example_table' will be too. The array keys here are the array Chris@0: // keys for the other tables, given in their hook_views_data() Chris@0: // implementations. If the table listed here is from another module's Chris@0: // hook_views_data() implementation, make sure your module depends on that Chris@0: // other module. Chris@0: 'node_field_data' => [ Chris@0: // Primary key field in node_field_data to use in the join. Chris@0: 'left_field' => 'nid', Chris@0: // Foreign key field in example_table to use in the join. Chris@0: 'field' => 'nid', Chris@0: // 'extra' is an array of additional conditions on the join. Chris@0: 'extra' => [ Chris@0: 0 => [ Chris@0: // Adds AND node_field_data.published = TRUE to the join. Chris@0: 'field' => 'published', Chris@0: 'value' => TRUE, Chris@0: ], Chris@0: 1 => [ Chris@0: // Adds AND example_table.numeric_field = 1 to the join. Chris@0: 'left_field' => 'numeric_field', Chris@0: 'value' => 1, Chris@0: // If true, the value will not be surrounded in quotes. Chris@0: 'numeric' => TRUE, Chris@0: ], Chris@0: 2 => [ Chris@0: // Adds AND example_table.boolean_field <> Chris@0: // node_field_data.published to the join. Chris@0: 'field' => 'published', Chris@0: 'left_field' => 'boolean_field', Chris@0: // The operator used, Defaults to "=". Chris@0: 'operator' => '!=', Chris@0: ], Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // You can also do a more complex join, where in order to get to a certain Chris@0: // base table defined in a hook_views_data() implementation, you will join Chris@0: // to a different table that Views knows how to auto-join to the base table. Chris@0: // For instance, if another module that your module depends on had Chris@0: // defined a table 'foo' with an automatic join to 'node_field_table' (as Chris@0: // shown above), you could join to 'node_field_table' via the 'foo' table. Chris@0: // Here's how to do this, and the resulting SQL query would look something Chris@0: // like this: Chris@0: // ... FROM example_table et ... JOIN foo foo Chris@0: // ON et.nid = foo.nid AND ('extra' clauses will be here) ... Chris@0: // JOIN node_field_data nfd ON (definition of the join from the foo Chris@0: // module goes here) ... Chris@0: // although the table aliases will be different. Chris@0: $data['example_table']['table']['join']['node_field_data'] = [ Chris@0: // 'node_field_data' above is the base we're joining to in Views. Chris@0: // 'left_table' is the table we're actually joining to, in order to get to Chris@0: // 'node_field_data'. It has to be something that Views knows how to join Chris@0: // to 'node_field_data'. Chris@0: 'left_table' => 'foo', Chris@0: 'left_field' => 'nid', Chris@0: 'field' => 'nid', Chris@0: // 'extra' is an array of additional conditions on the join. Chris@0: 'extra' => [ Chris@0: // This syntax matches additional fields in the two tables: Chris@0: // ... AND foo.langcode = example_table.langcode ... Chris@0: ['left_field' => 'langcode', 'field' => 'langcode'], Chris@0: // This syntax adds a condition on our table. 'operator' defaults to Chris@0: // '=' for non-array values, or 'IN' for array values. Chris@0: // ... AND example_table.numeric_field > 0 ... Chris@0: ['field' => 'numeric_field', 'value' => 0, 'numeric' => TRUE, 'operator' => '>'], Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Other array elements at the top level of your table's array describe Chris@0: // individual database table fields made available to Views. The array keys Chris@0: // are the names (unique within the table) used by Views for the fields, Chris@0: // usually equal to the database field names. Chris@0: // Chris@0: // Each field entry must have the following elements: Chris@0: // - title: Translated label for the field in the UI. Chris@0: // - help: Description of the field in the UI. Chris@0: // Chris@0: // Each field entry may also have one or more of the following elements, Chris@0: // describing "handlers" (plugins) for the field: Chris@0: // - relationship: Specifies a handler that allows this field to be used Chris@0: // to define a relationship to another table in Views. Chris@0: // - field: Specifies a handler to make it available to Views as a field. Chris@0: // - filter: Specifies a handler to make it available to Views as a filter. Chris@0: // - sort: Specifies a handler to make it available to Views as a sort. Chris@0: // - argument: Specifies a handler to make it available to Views as an Chris@0: // argument, or contextual filter as it is known in the UI. Chris@0: // - area: Specifies a handler to make it available to Views to add content Chris@0: // to the header, footer, or as no result behavior. Chris@0: // Chris@0: // Note that when specifying handlers, you must give the handler plugin ID Chris@0: // and you may also specify overrides for various settings that make up the Chris@0: // plugin definition. See examples below; the Boolean example demonstrates Chris@0: // setting overrides. Chris@0: Chris@0: // Node ID field, exposed as relationship only, since it is a foreign key Chris@0: // in this table. Chris@0: $data['example_table']['nid'] = [ Chris@0: 'title' => t('Example content'), Chris@0: 'help' => t('Relate example content to the node content'), Chris@0: Chris@0: // Define a relationship to the node_field_data table, so views whose Chris@0: // base table is example_table can add a relationship to nodes. To make a Chris@0: // relationship in the other direction, you can: Chris@0: // - Use hook_views_data_alter() -- see the function body example on that Chris@0: // hook for details. Chris@0: // - Use the implicit join method described above. Chris@0: 'relationship' => [ Chris@0: // Views name of the table to join to for the relationship. Chris@0: 'base' => 'node_field_data', Chris@0: // Database field name in the other table to join on. Chris@0: 'base field' => 'nid', Chris@0: // ID of relationship handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: // Default label for relationship in the UI. Chris@0: 'label' => t('Example node'), Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Plain text field, exposed as a field, sort, filter, and argument. Chris@0: $data['example_table']['plain_text_field'] = [ Chris@0: 'title' => t('Plain text field'), Chris@0: 'help' => t('Just a plain text field.'), Chris@0: Chris@0: 'field' => [ Chris@0: // ID of field handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: Chris@0: 'sort' => [ Chris@0: // ID of sort handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: Chris@0: 'filter' => [ Chris@0: // ID of filter handler plugin to use. Chris@0: 'id' => 'string', Chris@0: ], Chris@0: Chris@0: 'argument' => [ Chris@0: // ID of argument handler plugin to use. Chris@0: 'id' => 'string', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Numeric field, exposed as a field, sort, filter, and argument. Chris@0: $data['example_table']['numeric_field'] = [ Chris@0: 'title' => t('Numeric field'), Chris@0: 'help' => t('Just a numeric field.'), Chris@0: Chris@0: 'field' => [ Chris@0: // ID of field handler plugin to use. Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: Chris@0: 'sort' => [ Chris@0: // ID of sort handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: Chris@0: 'filter' => [ Chris@0: // ID of filter handler plugin to use. Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: Chris@0: 'argument' => [ Chris@0: // ID of argument handler plugin to use. Chris@0: 'id' => 'numeric', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Boolean field, exposed as a field, sort, and filter. The filter section Chris@0: // illustrates overriding various settings. Chris@0: $data['example_table']['boolean_field'] = [ Chris@0: 'title' => t('Boolean field'), Chris@0: 'help' => t('Just an on/off field.'), Chris@0: Chris@0: 'field' => [ Chris@0: // ID of field handler plugin to use. Chris@0: 'id' => 'boolean', Chris@0: ], Chris@0: Chris@0: 'sort' => [ Chris@0: // ID of sort handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: ], Chris@0: Chris@0: 'filter' => [ Chris@0: // ID of filter handler plugin to use. Chris@0: 'id' => 'boolean', Chris@0: // Override the generic field title, so that the filter uses a different Chris@0: // label in the UI. Chris@0: 'label' => t('Published'), Chris@0: // Override the default BooleanOperator filter handler's 'type' setting, Chris@0: // to display this as a "Yes/No" filter instead of a "True/False" filter. Chris@0: 'type' => 'yes-no', Chris@0: // Override the default Boolean filter handler's 'use_equal' setting, to Chris@0: // make the query use 'boolean_field = 1' instead of 'boolean_field <> 0'. Chris@0: 'use_equal' => TRUE, Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Integer timestamp field, exposed as a field, sort, and filter. Chris@0: $data['example_table']['timestamp_field'] = [ Chris@0: 'title' => t('Timestamp field'), Chris@0: 'help' => t('Just a timestamp field.'), Chris@0: Chris@0: 'field' => [ Chris@0: // ID of field handler plugin to use. Chris@0: 'id' => 'date', Chris@0: ], Chris@0: Chris@0: 'sort' => [ Chris@0: // ID of sort handler plugin to use. Chris@0: 'id' => 'date', Chris@0: ], Chris@0: Chris@0: 'filter' => [ Chris@0: // ID of filter handler plugin to use. Chris@0: 'id' => 'date', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Area example. Areas are not generally associated with actual data Chris@0: // tables and fields. This example is from views_views_data(), which defines Chris@0: // the "Global" table (not really a table, but a group of Fields, Filters, Chris@0: // etc. that are grouped into section "Global" in the UI). Here's the Chris@0: // definition of the generic "Text area": Chris@0: $data['views']['area'] = [ Chris@0: 'title' => t('Text area'), Chris@0: 'help' => t('Provide markup text for the area.'), Chris@0: 'area' => [ Chris@0: // ID of the area handler plugin to use. Chris@0: 'id' => 'text', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: return $data; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the table and field information from hook_views_data(). Chris@0: * Chris@0: * @param array $data Chris@0: * An array of all information about Views tables and fields, collected from Chris@0: * hook_views_data(), passed by reference. Chris@0: * Chris@0: * @see hook_views_data() Chris@0: */ Chris@0: function hook_views_data_alter(array &$data) { Chris@0: // Alter the title of the node_field_data:nid field in the Views UI. Chris@0: $data['node_field_data']['nid']['title'] = t('Node-Nid'); Chris@0: Chris@0: // Add an additional field to the users_field_data table. Chris@0: $data['users_field_data']['example_field'] = [ Chris@0: 'title' => t('Example field'), Chris@0: 'help' => t('Some example content that references a user'), Chris@0: Chris@0: 'field' => [ Chris@0: // ID of the field handler to use. Chris@0: 'id' => 'example_field', Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Change the handler of the node title field, presumably to a handler plugin Chris@0: // you define in your module. Give the ID of this plugin. Chris@0: $data['node_field_data']['title']['field']['id'] = 'node_title'; Chris@0: Chris@0: // Add a relationship that will allow a view whose base table is 'foo' (from Chris@0: // another module) to have a relationship to 'example_table' (from my module), Chris@0: // via joining foo.fid to example_table.eid. Chris@0: // Chris@0: // This relationship has to be added to the 'foo' Views data, which my module Chris@0: // does not control, so it must be done in hook_views_data_alter(), not Chris@0: // hook_views_data(). Chris@0: // Chris@0: // In Views data definitions, each field can have only one relationship. So Chris@0: // rather than adding this relationship directly to the $data['foo']['fid'] Chris@0: // field entry, which could overwrite an existing relationship, we define Chris@0: // a dummy field key to handle the relationship. Chris@0: $data['foo']['unique_dummy_name'] = [ Chris@0: 'title' => t('Title seen while adding relationship'), Chris@0: 'help' => t('More information about the relationship'), Chris@0: Chris@0: 'relationship' => [ Chris@0: // Views name of the table being joined to from foo. Chris@0: 'base' => 'example_table', Chris@0: // Database field name in example_table for the join. Chris@0: 'base field' => 'eid', Chris@0: // Real database field name in foo for the join, to override Chris@0: // 'unique_dummy_name'. Chris@0: 'field' => 'fid', Chris@0: // ID of relationship handler plugin to use. Chris@0: 'id' => 'standard', Chris@0: 'label' => t('Default label for relationship'), Chris@0: ], Chris@0: ]; Chris@0: Chris@0: // Note that the $data array is not returned – it is modified by reference. Chris@0: } Chris@0: Chris@0: /** Chris@0: * Override the default Views data for a Field API field. Chris@0: * Chris@0: * The field module's implementation of hook_views_data() invokes this for each Chris@0: * field storage, in the module that defines the field type. It is not invoked Chris@0: * in other modules. Chris@0: * Chris@0: * If no hook implementation exists, hook_views_data() falls back to Chris@0: * views_field_default_views_data(). Chris@0: * Chris@0: * @param \Drupal\field\FieldStorageConfigInterface $field_storage Chris@0: * The field storage config entity. Chris@0: * Chris@0: * @return array Chris@0: * An array of views data, in the same format as the return value of Chris@0: * hook_views_data(). Chris@0: * Chris@0: * @see views_views_data() Chris@0: * @see hook_field_views_data_alter() Chris@0: * @see hook_field_views_data_views_data_alter() Chris@0: */ Chris@0: function hook_field_views_data(\Drupal\field\FieldStorageConfigInterface $field_storage) { Chris@0: $data = views_field_default_views_data($field_storage); Chris@0: foreach ($data as $table_name => $table_data) { Chris@0: // Add the relationship only on the target_id field. Chris@0: $data[$table_name][$field_storage->getName() . '_target_id']['relationship'] = [ Chris@0: 'id' => 'standard', Chris@0: 'base' => 'file_managed', Chris@0: 'base field' => 'target_id', Chris@0: 'label' => t('image from @field_name', ['@field_name' => $field_storage->getName()]), Chris@0: ]; Chris@0: } Chris@0: Chris@0: return $data; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the Views data for a single Field API field. Chris@0: * Chris@0: * This is called on all modules even if there is no hook_field_views_data() Chris@0: * implementation for the field, and therefore may be used to alter the Chris@0: * default data that views_field_default_views_data() supplies for the Chris@0: * field storage. Chris@0: * Chris@0: * @param array $data Chris@0: * The views data for the field storage. This has the same format as the Chris@0: * return value of hook_views_data(). Chris@0: * @param \Drupal\field\FieldStorageConfigInterface $field_storage Chris@0: * The field storage config entity. Chris@0: * Chris@0: * @see views_views_data() Chris@0: * @see hook_field_views_data() Chris@0: * @see hook_field_views_data_views_data_alter() Chris@0: */ Chris@0: function hook_field_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field_storage) { Chris@0: $entity_type_id = $field_storage->getTargetEntityTypeId(); Chris@0: $field_name = $field_storage->getName(); Chris@0: $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); Chris@0: $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; Chris@0: $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); Chris@0: Chris@0: list($label) = views_entity_field_label($entity_type_id, $field_name); Chris@0: Chris@0: $data['file_managed'][$pseudo_field_name]['relationship'] = [ Chris@0: 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]), Chris@0: 'help' => t('Relate each @entity with a @field set to the image.', ['@entity' => $entity_type->getLabel(), '@field' => $label]), Chris@0: 'id' => 'entity_reverse', Chris@0: 'field_name' => $field_name, Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'field table' => $table_mapping->getDedicatedDataTableName($field_storage), Chris@0: 'field field' => $field_name . '_target_id', Chris@0: 'base' => $entity_type->getBaseTable(), Chris@0: 'base field' => $entity_type->getKey('id'), Chris@0: 'label' => $field_name, Chris@0: 'join_extra' => [ Chris@0: 0 => [ Chris@0: 'field' => 'deleted', Chris@0: 'value' => 0, Chris@0: 'numeric' => TRUE, Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the Views data on a per field basis. Chris@0: * Chris@0: * The field module's implementation of hook_views_data_alter() invokes this for Chris@0: * each field storage, in the module that defines the field type. It is not Chris@0: * invoked in other modules. Chris@0: * Chris@0: * Unlike hook_field_views_data_alter(), this operates on the whole of the views Chris@0: * data. This allows a field type to add data that concerns its fields in Chris@0: * other tables, which would not yet be defined at the point when Chris@0: * hook_field_views_data() and hook_field_views_data_alter() are invoked. For Chris@0: * example, entityreference adds reverse relationships on the tables for the Chris@0: * entities which are referenced by entityreference fields. Chris@0: * Chris@0: * (Note: this is weirdly named so as not to conflict with Chris@0: * hook_field_views_data_alter().) Chris@0: * Chris@0: * @param array $data Chris@0: * The views data. Chris@0: * @param \Drupal\field\FieldStorageConfigInterface $field Chris@0: * The field storage config entity. Chris@0: * Chris@0: * @see hook_field_views_data() Chris@0: * @see hook_field_views_data_alter() Chris@0: * @see views_views_data_alter() Chris@0: */ Chris@0: function hook_field_views_data_views_data_alter(array &$data, \Drupal\field\FieldStorageConfigInterface $field) { Chris@0: $field_name = $field->getName(); Chris@0: $data_key = 'field_data_' . $field_name; Chris@0: $entity_type_id = $field->entity_type; Chris@0: $entity_type = \Drupal::entityManager()->getDefinition($entity_type_id); Chris@0: $pseudo_field_name = 'reverse_' . $field_name . '_' . $entity_type_id; Chris@0: list($label) = views_entity_field_label($entity_type_id, $field_name); Chris@0: $table_mapping = \Drupal::entityManager()->getStorage($entity_type_id)->getTableMapping(); Chris@0: Chris@0: // Views data for this field is in $data[$data_key]. Chris@0: $data[$data_key][$pseudo_field_name]['relationship'] = [ Chris@0: 'title' => t('@entity using @field', ['@entity' => $entity_type->getLabel(), '@field' => $label]), Chris@0: 'help' => t('Relate each @entity with a @field set to the term.', ['@entity' => $entity_type->getLabel(), '@field' => $label]), Chris@0: 'id' => 'entity_reverse', Chris@0: 'field_name' => $field_name, Chris@0: 'entity_type' => $entity_type_id, Chris@0: 'field table' => $table_mapping->getDedicatedDataTableName($field), Chris@0: 'field field' => $field_name . '_target_id', Chris@0: 'base' => $entity_type->getBaseTable(), Chris@0: 'base field' => $entity_type->getKey('id'), Chris@0: 'label' => $field_name, Chris@0: 'join_extra' => [ Chris@0: 0 => [ Chris@0: 'field' => 'deleted', Chris@0: 'value' => 0, Chris@0: 'numeric' => TRUE, Chris@0: ], Chris@0: ], Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Replace special strings in the query before it is executed. Chris@0: * Chris@0: * The idea is that certain dynamic values can be placed in a query when it is Chris@0: * built, and substituted at run-time, allowing the query to be cached and Chris@0: * still work correctly when executed. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The View being executed. Chris@0: * Chris@0: * @return array Chris@0: * An associative array where each key is a string to be replaced, and the Chris@0: * corresponding value is its replacement. The strings to replace are often Chris@0: * surrounded with '***', as illustrated in the example implementation, to Chris@0: * avoid collisions with other values in the query. Chris@0: */ Chris@0: function hook_views_query_substitutions(ViewExecutable $view) { Chris@0: // Example from views_views_query_substitutions(). Chris@0: return [ Chris@0: '***CURRENT_VERSION***' => \Drupal::VERSION, Chris@0: '***CURRENT_TIME***' => REQUEST_TIME, Chris@0: '***LANGUAGE_language_content***' => \Drupal::languageManager()->getCurrentLanguage(LanguageInterface::TYPE_CONTENT)->getId(), Chris@0: PluginBase::VIEWS_QUERY_LANGUAGE_SITE_DEFAULT => \Drupal::languageManager()->getDefaultLanguage()->getId(), Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Replace special strings when processing a view with form elements. Chris@0: * Chris@0: * @return array Chris@0: * An associative array where each key is a string to be replaced, and the Chris@0: * corresponding value is its replacement. The value will be escaped unless it Chris@0: * is already marked safe. Chris@0: */ Chris@0: function hook_views_form_substitutions() { Chris@0: return [ Chris@0: '' => 'Example Substitution', Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter a view at the very beginning of Views processing. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * @param string $display_id Chris@0: * The machine name of the active display. Chris@0: * @param array $args Chris@0: * An array of arguments passed into the view. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_pre_view(ViewExecutable $view, $display_id, array &$args) { Chris@0: Chris@0: // Modify contextual filters for my_special_view if user has 'my special permission'. Chris@0: $account = \Drupal::currentUser(); Chris@0: Chris@0: if ($view->id() == 'my_special_view' && $account->hasPermission('my special permission') && $display_id == 'public_display') { Chris@0: $args[0] = 'custom value'; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Act on the view before the query is built, but after displays are attached. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_pre_build(ViewExecutable $view) { Chris@0: // Because of some inexplicable business logic, we should remove all Chris@0: // attachments from all views on Mondays. Chris@0: // (This alter could be done later in the execution process as well.) Chris@0: if (date('D') == 'Mon') { Chris@0: unset($view->attachment_before); Chris@0: unset($view->attachment_after); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Act on the view immediately after the query is built. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_post_build(ViewExecutable $view) { Chris@0: // If the exposed field 'type' is set, hide the column containing the content Chris@0: // type. (Note that this is a solution for a particular view, and makes Chris@0: // assumptions about both exposed filter settings and the fields in the view. Chris@0: // Also note that this alter could be done at any point before the view being Chris@0: // rendered.) Chris@0: if ($view->id() == 'my_view' && isset($view->exposed_raw_input['type']) && $view->exposed_raw_input['type'] != 'All') { Chris@0: // 'Type' should be interpreted as content type. Chris@0: if (isset($view->field['type'])) { Chris@0: $view->field['type']->options['exclude'] = TRUE; Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Act on the view after the query is built and just before it is executed. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_pre_execute(ViewExecutable $view) { Chris@0: // Whenever a view queries more than two tables, show a message that notifies Chris@0: // view administrators that the query might be heavy. Chris@0: // (This action could be performed later in the execution process, but not Chris@0: // earlier.) Chris@0: $account = \Drupal::currentUser(); Chris@0: Chris@0: if (count($view->query->tables) > 2 && $account->hasPermission('administer views')) { Chris@17: \Drupal::messenger()->addWarning(t('The view %view may be heavy to execute.', ['%view' => $view->id()])); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Act on the view immediately after the query has been executed. Chris@0: * Chris@0: * At this point the query has been executed, but the preRender() phase has Chris@0: * not yet happened for handlers. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_post_execute(ViewExecutable $view) { Chris@0: // If there are more than 100 results, show a message that encourages the user Chris@0: // to change the filter settings. Chris@0: // (This action could be performed later in the execution process, but not Chris@0: // earlier.) Chris@0: if ($view->total_rows > 100) { Chris@17: \Drupal::messenger()->addStatus(t('You have more than 100 hits. Use the filter settings to narrow down your list.')); Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Act on the view immediately before rendering it. Chris@0: * Chris@0: * At this point the query has been executed, and the preRender() phase has Chris@0: * already happened for handlers, so all data should be available. This hook Chris@0: * can be used by themes. Chris@0: * Chris@0: * Output can be added to the view by setting $view->attachment_before Chris@0: * and $view->attachment_after. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_pre_render(ViewExecutable $view) { Chris@0: // Scramble the order of the rows shown on this result page. Chris@0: // Note that this could be done earlier, but not later in the view execution Chris@0: // process. Chris@0: shuffle($view->result); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Post-process any rendered data. Chris@0: * Chris@0: * This can be valuable to be able to cache a view and still have some level of Chris@0: * dynamic output. In an ideal world, the actual output will include HTML Chris@0: * comment-based tokens, and then the post process can replace those tokens. Chris@0: * This hook can be used by themes. Chris@0: * Chris@0: * Example usage. If it is known that the view is a node view and that the Chris@0: * primary field will be a nid, you can do something like this: Chris@0: * @code Chris@0: * Chris@0: * @endcode Chris@0: * And then in the post-render, create an array with the text that should Chris@0: * go there: Chris@0: * @code Chris@0: * strtr($output, array('' => 'output for FIELD of nid 1'); Chris@0: * @endcode Chris@0: * All of the cached result data will be available in $view->result, as well, Chris@0: * so all ids used in the query should be discoverable. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * @param string $output Chris@0: * A flat string with the rendered output of the view. Chris@0: * @param \Drupal\views\Plugin\views\cache\CachePluginBase $cache Chris@0: * The cache settings. Chris@0: * Chris@0: * @see \Drupal\views\ViewExecutable Chris@0: */ Chris@0: function hook_views_post_render(ViewExecutable $view, &$output, CachePluginBase $cache) { Chris@0: // When using full pager, disable any time-based caching if there are fewer Chris@0: // than 10 results. Chris@0: if ($view->pager instanceof Drupal\views\Plugin\views\pager\Full && $cache instanceof Drupal\views\Plugin\views\cache\Time && count($view->result) < 10) { Chris@0: $cache->options['results_lifespan'] = 0; Chris@0: $cache->options['output_lifespan'] = 0; Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the query before it is executed. Chris@0: * Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object about to be processed. Chris@0: * @param QueryPluginBase $query Chris@0: * The query plugin object for the query. Chris@0: * Chris@0: * @see hook_views_query_substitutions() Chris@0: * @see \Drupal\views\Plugin\views\query\Sql Chris@0: */ Chris@0: function hook_views_query_alter(ViewExecutable $view, QueryPluginBase $query) { Chris@0: // (Example assuming a view with an exposed filter on node title.) Chris@0: // If the input for the title filter is a positive integer, filter against Chris@0: // node ID instead of node title. Chris@0: if ($view->id() == 'my_view' && is_numeric($view->exposed_raw_input['title']) && $view->exposed_raw_input['title'] > 0) { Chris@0: // Traverse through the 'where' part of the query. Chris@0: foreach ($query->where as &$condition_group) { Chris@0: foreach ($condition_group['conditions'] as &$condition) { Chris@0: // If this is the part of the query filtering on title, chang the Chris@0: // condition to filter on node ID. Chris@0: if ($condition['field'] == 'node.title') { Chris@0: $condition = [ Chris@0: 'field' => 'node.nid', Chris@0: 'value' => $view->exposed_raw_input['title'], Chris@0: 'operator' => '=', Chris@0: ]; Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the view preview information. Chris@0: * Chris@0: * The view preview information is optionally displayed when a view is Chris@0: * previewed in the administrative UI. It includes query and performance Chris@0: * statistics. Chris@0: * Chris@0: * @param array $rows Chris@0: * An associative array with two keys: Chris@0: * - query: An array of rows suitable for '#type' => 'table', containing Chris@0: * information about the query and the display title and path. Chris@0: * - statistics: An array of rows suitable for '#type' => 'table', Chris@0: * containing performance statistics. Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object. Chris@0: * Chris@0: * @see \Drupal\views_ui\ViewUI Chris@0: * @see table.html.twig Chris@0: */ Chris@0: function hook_views_preview_info_alter(array &$rows, ViewExecutable $view) { Chris@0: // Adds information about the tables being queried by the view to the query Chris@0: // part of the info box. Chris@0: $rows['query'][] = [ Chris@0: t('Table queue'), Chris@0: count($view->query->table_queue) . ': (' . implode(', ', array_keys($view->query->table_queue)) . ')', Chris@0: ]; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Alter the links displayed at the top of the view edit form. Chris@0: * Chris@0: * @param array $links Chris@0: * A renderable array of links which will be displayed at the top of the Chris@0: * view edit form. Each entry will be in a form suitable for Chris@0: * '#theme' => 'links'. Chris@0: * @param \Drupal\views\ViewExecutable $view Chris@0: * The view object being edited. Chris@0: * @param string $display_id Chris@0: * The ID of the display being edited, e.g. 'default' or 'page_1'. Chris@0: * Chris@0: * @see \Drupal\views_ui\ViewUI::renderDisplayTop() Chris@0: */ Chris@0: function hook_views_ui_display_top_links_alter(array &$links, ViewExecutable $view, $display_id) { Chris@0: // Put the export link first in the list. Chris@0: if (isset($links['export'])) { Chris@0: $links = ['export' => $links['export']] + $links; Chris@0: } Chris@0: } Chris@0: Chris@0: // @todo Describe how to alter a view ajax response with event listeners. Chris@0: Chris@0: /** Chris@0: * Allow modules to respond to the invalidation of the Views cache. Chris@0: * Chris@0: * This hook will fire whenever a view is enabled, disabled, created, Chris@0: * updated, or deleted. Chris@0: * Chris@0: * @see views_invalidate_cache() Chris@0: */ Chris@0: function hook_views_invalidate_cache() { Chris@0: \Drupal\Core\Cache\Cache::invalidateTags(['views']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views access plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_access_alter(array &$plugins) { Chris@0: // Remove the available plugin because the users should not have access to it. Chris@0: unset($plugins['role']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views default argument plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_argument_default_alter(array &$plugins) { Chris@0: // Remove the available plugin because the users should not have access to it. Chris@0: unset($plugins['php']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views argument validation plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_argument_validator_alter(array &$plugins) { Chris@0: // Remove the available plugin because the users should not have access to it. Chris@0: unset($plugins['php']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views cache plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_cache_alter(array &$plugins) { Chris@0: // Change the title. Chris@0: $plugins['time']['title'] = t('Custom title'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views display extender plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_display_extenders_alter(array &$plugins) { Chris@0: // Alter the title of an existing plugin. Chris@0: $plugins['time']['title'] = t('Custom title'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views display plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_display_alter(array &$plugins) { Chris@0: // Alter the title of an existing plugin. Chris@0: $plugins['rest_export']['title'] = t('Export'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views exposed form plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_exposed_form_alter(array &$plugins) { Chris@0: // Remove the available plugin because the users should not have access to it. Chris@0: unset($plugins['input_required']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views join plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_join_alter(array &$plugins) { Chris@0: // Print out all join plugin names for debugging purposes. Chris@0: debug($plugins); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views pager plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_pager_alter(array &$plugins) { Chris@0: // Remove the sql based plugin to force good performance. Chris@0: unset($plugins['full']); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views query plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_query_alter(array &$plugins) { Chris@0: // Print out all query plugin names for debugging purposes. Chris@0: debug($plugins); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views row plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_row_alter(array &$plugins) { Chris@0: // Change the used class of a plugin. Chris@0: $plugins['entity:node']['class'] = 'Drupal\node\Plugin\views\row\NodeRow'; Chris@0: $plugins['entity:node']['module'] = 'node'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views style plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_style_alter(array &$plugins) { Chris@0: // Change the theme hook of a plugin. Chris@0: $plugins['html_list']['theme'] = 'custom_views_view_list'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views wizard plugins. Chris@0: * Chris@0: * This hook may be used to modify plugin properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing plugin definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsPluginManager Chris@0: */ Chris@0: function hook_views_plugins_wizard_alter(array &$plugins) { Chris@0: // Change the title of a plugin. Chris@0: $plugins['node_revision']['title'] = t('Node revision wizard'); Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views area handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_area_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views argument handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_argument_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views field handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_field_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views filter handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_filter_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views relationship handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_relationship_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * Modify the list of available views sort handler plugins. Chris@0: * Chris@0: * This hook may be used to modify handler properties after they have been Chris@0: * specified by other modules. Chris@0: * Chris@0: * @param array $plugins Chris@0: * An array of all the existing handler definitions, passed by reference. Chris@0: * Chris@0: * @see \Drupal\views\Plugin\ViewsHandlerManager Chris@0: */ Chris@0: function hook_views_plugins_sort_alter(array &$plugins) { Chris@0: // Change the 'title' handler class. Chris@0: $plugins['title']['class'] = 'Drupal\\example\\ExampleClass'; Chris@0: } Chris@0: Chris@0: /** Chris@0: * @} End of "addtogroup hooks". Chris@0: */ Chris@0: Chris@0: /** Chris@0: * @} Chris@0: */