class SupportTicket in Support Ticketing System 8
Same name in this branch
- 8 modules/support_ticket/src/Entity/SupportTicket.php \Drupal\support_ticket\Entity\SupportTicket
- 8 modules/support_ticket/src/Plugin/views/argument_default/SupportTicket.php \Drupal\support_ticket\Plugin\views\argument_default\SupportTicket
- 8 modules/support_ticket/src/Plugin/views/wizard/SupportTicket.php \Drupal\support_ticket\Plugin\views\wizard\SupportTicket
- 8 modules/support_ticket/src/Plugin/views/field/SupportTicket.php \Drupal\support_ticket\Plugin\views\field\SupportTicket
- 8 modules/support_ticket/src/Plugin/migrate/source/d6/SupportTicket.php \Drupal\support_ticket\Plugin\migrate\source\d6\SupportTicket
Tests creating support ticket views with the wizard.
Plugin annotation
@ViewsWizard(
id = "support_ticket",
base_table = "support_ticket_field_data",
title = @Translation("Support tickets")
)
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\wizard\WizardPluginBase implements WizardInterface uses UrlGeneratorTrait
- class \Drupal\support_ticket\Plugin\views\wizard\SupportTicket
- class \Drupal\views\Plugin\views\wizard\WizardPluginBase implements WizardInterface uses UrlGeneratorTrait
- class \Drupal\views\Plugin\views\PluginBase implements DependentPluginInterface, ContainerFactoryPluginInterface, TrustedCallbackInterface, ViewsPluginInterface
- class \Drupal\Core\Plugin\PluginBase uses DependencySerializationTrait, MessengerTrait, StringTranslationTrait
Expanded class hierarchy of SupportTicket
File
- modules/
support_ticket/ src/ Plugin/ views/ wizard/ SupportTicket.php, line 26 - Contains \Drupal\support_ticket\Plugin\views\wizard\SupportTicket.
Namespace
Drupal\support_ticket\Plugin\views\wizardView source
class SupportTicket extends WizardPluginBase {
/**
* Set the created column.
*/
protected $createdColumn = 'support_ticket_field_data-created';
/**
* Set default values for the filters.
*/
protected $filters = array(
'status' => array(
'value' => TRUE,
'table' => 'support_ticket_field_data',
'field' => 'status',
'plugin_id' => 'boolean',
'entity_type' => 'support_ticket',
'entity_field' => 'status',
),
);
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::getAvailableSorts().
*
* @return array
* An array whose keys are the available sort options and whose
* corresponding values are human readable labels.
*/
public function getAvailableSorts() {
// You can't execute functions in properties, so override the method
return array(
'support_ticket_field_data-title:DESC' => $this
->t('Title'),
);
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::rowStyleOptions().
*/
protected function rowStyleOptions() {
$options = array();
$options['teasers'] = $this
->t('teasers');
$options['full_posts'] = $this
->t('full posts');
$options['titles'] = $this
->t('titles');
$options['titles_linked'] = $this
->t('titles (linked)');
$options['fields'] = $this
->t('fields');
return $options;
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions().
*/
protected function defaultDisplayOptions() {
$display_options = parent::defaultDisplayOptions();
// Add permission-based access control.
$display_options['access']['type'] = 'perm';
$display_options['access']['options']['perm'] = 'access support tickets';
// Remove the default fields, since we are customizing them here.
unset($display_options['fields']);
// Add the title field, so that the display has content if the user switches
// to a row style that uses fields.
/* Field: Support ticket: Title */
$display_options['fields']['title']['id'] = 'title';
$display_options['fields']['title']['table'] = 'support_ticket_field_data';
$display_options['fields']['title']['field'] = 'title';
$display_options['fields']['title']['entity_type'] = 'support_ticket';
$display_options['fields']['title']['entity_field'] = 'title';
$display_options['fields']['title']['label'] = '';
$display_options['fields']['title']['alter']['alter_text'] = 0;
$display_options['fields']['title']['alter']['make_link'] = 0;
$display_options['fields']['title']['alter']['absolute'] = 0;
$display_options['fields']['title']['alter']['trim'] = 0;
$display_options['fields']['title']['alter']['word_boundary'] = 0;
$display_options['fields']['title']['alter']['ellipsis'] = 0;
$display_options['fields']['title']['alter']['strip_tags'] = 0;
$display_options['fields']['title']['alter']['html'] = 0;
$display_options['fields']['title']['hide_empty'] = 0;
$display_options['fields']['title']['empty_zero'] = 0;
$display_options['fields']['title']['settings']['link_to_entity'] = 1;
$display_options['fields']['title']['plugin_id'] = 'field';
return $display_options;
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser().
*/
protected function defaultDisplayFiltersUser(array $form, FormStateInterface $form_state) {
$filters = parent::defaultDisplayFiltersUser($form, $form_state);
$tids = array();
if ($values = $form_state
->getValue(array(
'show',
'tagged_with',
))) {
foreach ($values as $value) {
$tids[] = $value['target_id'];
}
}
if (!empty($tids)) {
$vid = reset($form['displays']['show']['tagged_with']['#selection_settings']['target_bundles']);
$filters['tid'] = array(
'id' => 'tid',
'table' => 'taxonomy_index',
'field' => 'tid',
'value' => $tids,
'vid' => $vid,
'plugin_id' => 'taxonomy_index_tid',
);
// If the user entered more than one valid term in the autocomplete
// field, they probably intended both of them to be applied.
if (count($tids) > 1) {
$filters['tid']['operator'] = 'and';
// Sort the terms so the filter will be displayed as it normally would
// on the edit screen.
sort($filters['tid']['value']);
}
}
return $filters;
}
/**
* {@inheritdoc}
*/
protected function pageDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::pageDisplayOptions($form, $form_state);
$row_plugin = $form_state
->getValue(array(
'page',
'style',
'row_plugin',
));
$row_options = $form_state
->getValue(array(
'page',
'style',
'row_options',
), array());
$this
->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
/**
* {@inheritdoc}
*/
protected function blockDisplayOptions(array $form, FormStateInterface $form_state) {
$display_options = parent::blockDisplayOptions($form, $form_state);
$row_plugin = $form_state
->getValue(array(
'block',
'style',
'row_plugin',
));
$row_options = $form_state
->getValue(array(
'block',
'style',
'row_options',
), array());
$this
->display_options_row($display_options, $row_plugin, $row_options);
return $display_options;
}
/**
* Set the row style and row style plugins to the display_options.
*/
protected function display_options_row(&$display_options, $row_plugin, $row_options) {
switch ($row_plugin) {
case 'full_posts':
$display_options['row']['type'] = 'entity:support_ticket';
$display_options['row']['options']['view_mode'] = 'full';
break;
case 'teasers':
$display_options['row']['type'] = 'entity:support_ticket';
$display_options['row']['options']['view_mode'] = 'teaser';
break;
case 'titles_linked':
case 'titles':
$display_options['row']['type'] = 'fields';
$display_options['fields']['title']['id'] = 'title';
$display_options['fields']['title']['table'] = 'support_ticket_field_data';
$display_options['fields']['title']['field'] = 'title';
$display_options['fields']['title']['settings']['link_to_entity'] = $row_plugin === 'titles_linked';
$display_options['fields']['title']['plugin_id'] = 'field';
break;
}
}
/**
* Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters().
*
* Add some options for filter by taxonomy terms.
*/
protected function buildFilters(&$form, FormStateInterface $form_state) {
parent::buildFilters($form, $form_state);
$selected_bundle = static::getSelected($form_state, array(
'show',
'type',
), 'all', $form['displays']['show']['type']);
// Add the "tagged with" filter to the view.
// We construct this filter using taxonomy_index.tid (which limits the
// filtering to a specific vocabulary) rather than
// taxonomy_term_field_data.name (which matches terms in any vocabulary).
// This is because it is a more commonly-used filter that works better with
// the autocomplete UI, and also to avoid confusion with other vocabularies
// on the site that may have terms with the same name but are not used for
// free tagging.
// The downside is that if there *is* more than one vocabulary on the site
// that is used for free tagging, the wizard will only be able to make the
// "tagged with" filter apply to one of them (see below for the method it
// uses to choose).
// Find all "tag-like" taxonomy fields associated with the view's
// entities. If a particular entity type (i.e., bundle) has been
// selected above, then we only search for taxonomy fields associated
// with that bundle. Otherwise, we use all bundles.
$bundles = array_keys(entity_get_bundles($this->entityTypeId));
// Double check that this is a real bundle before using it (since above
// we added a dummy option 'all' to the bundle list on the form).
if (isset($selected_bundle) && in_array($selected_bundle, $bundles)) {
$bundles = array(
$selected_bundle,
);
}
$tag_fields = array();
foreach ($bundles as $bundle) {
$display = entity_get_form_display($this->entityTypeId, $bundle, 'default');
$taxonomy_fields = array_filter(\Drupal::entityManager()
->getFieldDefinitions($this->entityTypeId, $bundle), function ($field_definition) {
return $field_definition
->getType() == 'entity_reference' && $field_definition
->getSetting('target_type') == 'taxonomy_term';
});
foreach ($taxonomy_fields as $field_name => $field) {
$widget = $display
->getComponent($field_name);
// We define "tag-like" taxonomy fields as ones that use the
// "Autocomplete (Tags style)" widget.
if ($widget['type'] == 'entity_reference_autocomplete_tags') {
$tag_fields[$field_name] = $field;
}
}
}
if (!empty($tag_fields)) {
// If there is more than one "tag-like" taxonomy field available to
// the view, we can only make our filter apply to one of them (as
// described above). We choose 'field_tags' if it is available, since
// that is created by the Standard install profile in core and also
// commonly used by contrib modules; thus, it is most likely to be
// associated with the "main" free-tagging vocabulary on the site.
if (array_key_exists('field_tags', $tag_fields)) {
$tag_field_name = 'field_tags';
}
else {
$tag_field_name = key($tag_fields);
}
// Add the autocomplete textfield to the wizard.
$target_bundles = $tag_fields[$tag_field_name]
->getSetting('handler_settings')['target_bundles'];
$form['displays']['show']['tagged_with'] = array(
'#type' => 'entity_autocomplete',
'#title' => $this
->t('tagged with'),
'#target_type' => 'taxonomy_term',
'#selection_settings' => [
'target_bundles' => $target_bundles,
],
'#tags' => TRUE,
'#size' => 30,
'#maxlength' => 1024,
);
}
}
}
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 | |
MessengerTrait:: |
protected | property | The messenger. | 29 |
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:: |
public | function |
Provide a form to edit options for this plugin. Overrides ViewsPluginInterface:: |
16 |
PluginBase:: |
public | function |
Calculates dependencies for the configured plugin. Overrides DependentPluginInterface:: |
14 |
PluginBase:: |
protected | function | Information about options for all kinds of purposes will be held here. | 18 |
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 |
Initialize the plugin. Overrides ViewsPluginInterface:: |
8 |
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 | function |
Add anything to the query that we might need to. Overrides ViewsPluginInterface:: |
8 |
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 |
Handle any special handling on the validate form. Overrides ViewsPluginInterface:: |
16 |
PluginBase:: |
public | function |
Returns the summary of the settings in the display. Overrides ViewsPluginInterface:: |
6 |
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:: |
public | function |
Validate the options form. Overrides ViewsPluginInterface:: |
15 |
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. | ||
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. | |
SupportTicket:: |
protected | property |
Set the created column. Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | property |
Set default values for the filters. Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Retrieves the block display options. Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::buildFilters(). Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayFiltersUser(). Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions(). Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function | Set the row style and row style plugins to the display_options. | |
SupportTicket:: |
public | function |
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::getAvailableSorts(). Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Retrieves the page display options. Overrides WizardPluginBase:: |
|
SupportTicket:: |
protected | function |
Overrides Drupal\views\Plugin\views\wizard\WizardPluginBase::rowStyleOptions(). Overrides WizardPluginBase:: |
|
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. | ||
UrlGeneratorTrait:: |
protected | property | The url generator. | |
UrlGeneratorTrait:: |
protected | function | Returns the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Returns a redirect response object for the specified route. | 3 |
UrlGeneratorTrait:: |
public | function | Sets the URL generator service. | |
UrlGeneratorTrait:: |
protected | function | Generates a URL or path for a specific route based on the given parameters. | |
WizardPluginBase:: |
protected | property | The available store criteria. | |
WizardPluginBase:: |
protected | property | The base table connected with the wizard. | |
WizardPluginBase:: |
protected | property | The bundle info service. | |
WizardPluginBase:: |
protected | property | Contains the information from entity_get_info of the $entity_type. | |
WizardPluginBase:: |
protected | property | The entity type connected with the wizard. | |
WizardPluginBase:: |
protected | property | Default values for filters. | |
WizardPluginBase:: |
protected | property | Views items configuration arrays for sorts added by the wizard. | |
WizardPluginBase:: |
protected | property | An array of validated view objects, keyed by a hash. | |
WizardPluginBase:: |
protected | function | Adds the array of display options to the view, with appropriate overrides. | |
WizardPluginBase:: |
protected | function | Alters the full array of display options before they are added to the view. | |
WizardPluginBase:: |
protected | function | Builds an array of display options for the view. | 1 |
WizardPluginBase:: |
public | function |
Form callback to build other elements in the "show" form. Overrides WizardInterface:: |
|
WizardPluginBase:: |
protected | function | Adds the style options to the wizard form. | |
WizardPluginBase:: |
protected | function | Builds the form structure for selecting the view's sort order. | |
WizardPluginBase:: |
public static | function |
Creates an instance of the plugin. Overrides PluginBase:: |
1 |
WizardPluginBase:: |
public | function |
Creates a view from values that have already been validated. Overrides WizardInterface:: |
|
WizardPluginBase:: |
protected | function | Retrieves all filter information used by the default display. | |
WizardPluginBase:: |
protected | function | Retrieves all sort information used by the default display. | |
WizardPluginBase:: |
protected | function | Retrieves sort information based on user input for the default display. | |
WizardPluginBase:: |
public | function | Gets the createdColumn property. | |
WizardPluginBase:: |
public | function | Gets the filters property. | 1 |
WizardPluginBase:: |
public static | function | Gets the current value of a #select element, from within a form constructor function. | |
WizardPluginBase:: |
public | function | Gets the sorts property. | |
WizardPluginBase:: |
protected | function | Instantiates a view object from form values. | |
WizardPluginBase:: |
protected | function | Retrieves the feed display options. | |
WizardPluginBase:: |
protected | function | Retrieves the REST export display options from the submitted form values. | |
WizardPluginBase:: |
protected | function | Retrieves a validated view for a form submission. | |
WizardPluginBase:: |
protected | function | Sets options for a display and makes them the default options if possible. | |
WizardPluginBase:: |
protected | function | Sets options for a display, inheriting from the defaults when possible. | |
WizardPluginBase:: |
protected | function | Stores a validated view from a form submission. | |
WizardPluginBase:: |
public | function |
Implements Drupal\views\Plugin\views\wizard\WizardInterface::validate(). Overrides WizardInterface:: |
|
WizardPluginBase:: |
public | function |
Constructs a WizardPluginBase object. Overrides PluginBase:: |
1 |