You are here

class SupportTicketPreviewConverter in Support Ticketing System 8

Same name in this branch
  1. 8 modules/support_ticket/src/ParamConverter/SupportTicketPreviewConverter.php \Drupal\support_ticket\ParamConverter\SupportTicketPreviewConverter
  2. 8 modules/support_ticket/src/ProxyClass/ParamConverter/SupportTicketPreviewConverter.php \Drupal\support_ticket\ProxyClass\ParamConverter\SupportTicketPreviewConverter

Provides upcasting for a support ticket entity in preview.

Hierarchy

Expanded class hierarchy of SupportTicketPreviewConverter

1 string reference to 'SupportTicketPreviewConverter'
support_ticket.services.yml in modules/support_ticket/support_ticket.services.yml
modules/support_ticket/support_ticket.services.yml
1 service uses SupportTicketPreviewConverter
support_ticket_preview in modules/support_ticket/support_ticket.services.yml
Drupal\support_ticket\ParamConverter\SupportTicketPreviewConverter

File

modules/support_ticket/src/ParamConverter/SupportTicketPreviewConverter.php, line 18
Contains \Drupal\support_ticket\ParamConverter\SupportTicketPreviewConverter.

Namespace

Drupal\support_ticket\ParamConverter
View source
class SupportTicketPreviewConverter implements ParamConverterInterface {

  /**
   * Stores the tempstore factory.
   *
   * @var \Drupal\user\PrivateTempStoreFactory
   */
  protected $tempStoreFactory;

  /**
   * Constructs a new SupportTicketPreviewConverter.
   *
   * @param \Drupal\user\PrivateTempStoreFactory $temp_store_factory
   *   The factory for the temp store object.
   */
  public function __construct(PrivateTempStoreFactory $temp_store_factory) {
    $this->tempStoreFactory = $temp_store_factory;
  }

  /**
   * {@inheritdoc}
   */
  public function convert($value, $definition, $name, array $defaults) {
    $store = $this->tempStoreFactory
      ->get('support_ticket_preview');
    if ($form_state = $store
      ->get($value)) {
      return $form_state
        ->getFormObject()
        ->getEntity();
    }
  }

  /**
   * {@inheritdoc}
   */
  public function applies($definition, $name, Route $route) {
    if (!empty($definition['type']) && $definition['type'] == 'support_ticket_preview') {
      return TRUE;
    }
    return FALSE;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
SupportTicketPreviewConverter::$tempStoreFactory protected property Stores the tempstore factory.
SupportTicketPreviewConverter::applies public function Determines if the converter applies to a specific route and variable. Overrides ParamConverterInterface::applies
SupportTicketPreviewConverter::convert public function Converts path variables to their corresponding objects. Overrides ParamConverterInterface::convert
SupportTicketPreviewConverter::__construct public function Constructs a new SupportTicketPreviewConverter.