Type.php in Support Ticketing System 8
File
modules/support_ticket/src/Plugin/views/argument/Type.php
View source
<?php
namespace Drupal\support_ticket\Plugin\views\argument;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\views\Plugin\views\argument\StringArgument;
use Symfony\Component\DependencyInjection\ContainerInterface;
class Type extends StringArgument {
protected $supportTicketTypeStorage;
public function __construct(array $configuration, $plugin_id, $plugin_definition, EntityStorageInterface $support_ticket_type_storage) {
parent::__construct($configuration, $plugin_id, $plugin_definition);
$this->supportTicketTypeStorage = $support_ticket_type_storage;
}
public static function create(ContainerInterface $container, array $configuration, $plugin_id, $plugin_definition) {
$entity_manager = $container
->get('entity.manager');
return new static($configuration, $plugin_id, $plugin_definition, $entity_manager
->getStorage('support_ticket_type'));
}
public function summaryName($data) {
return $this
->support_ticket_type($data->{$this->name_alias});
}
function title() {
return $this
->support_ticket_type($this->argument);
}
function support_ticket_type($type_name) {
$type = $this->supportTicketTypeStorage
->load($type_name);
$output = $type ? $type
->label() : $this
->t('Unknown support ticket type');
return SafeMarkup::checkPlain($output);
}
}
Classes
Name |
Description |
Type |
Argument handler to accept a support ticket type. |