You are here

public function UnpublishByKeywordSupportTicket::execute in Support Ticketing System 8

Executes the plugin.

Overrides ExecutableInterface::execute

File

modules/support_ticket/src/Plugin/Action/UnpublishByKeywordSupportTicket.php, line 29
Contains \Drupal\support_ticket\Plugin\Action\UnpublishByKeywordSupportTicket.

Class

UnpublishByKeywordSupportTicket
Unpublishes a support ticket containing certain keywords.

Namespace

Drupal\support_ticket\Plugin\Action

Code

public function execute($support_ticket = NULL) {
  foreach ($this->configuration['keywords'] as $keyword) {
    $elements = support_ticket_view(clone $support_ticket);
    if (strpos(drupal_render($elements), $keyword) !== FALSE || strpos($support_ticket
      ->label(), $keyword) !== FALSE) {
      $support_ticket
        ->setPublished(FALSE);
      $support_ticket
        ->save();
      break;
    }
  }
}