/** * {@inheritdoc} */ 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; } } }
public function render($row) { global $base_url; $stid = $row->{$this->field_alias}; if (!is_numeric($stid)) { return; } $display_mode = $this->options['view_mode']; if ($display_mode == 'default') { $display_mode = \Drupal::config('system.rss')->get('items.view_mode'); } // Load the specified support ticket: /** @var \Drupal\support_ticket\SupportTicketInterface $support_ticket */ $support_ticket = $this->support_tickets[$stid]; if (empty($support_ticket)) { return; } $description_build = []; $support_ticket->link = $support_ticket->url('canonical', array('absolute' => TRUE)); $support_ticket->rss_namespaces = array(); $support_ticket->rss_elements = array(array('key' => 'pubDate', 'value' => gmdate('r', $support_ticket->getCreatedTime())), array('key' => 'dc:creator', 'value' => $support_ticket->getOwner()->getDisplayName()), array('key' => 'guid', 'value' => $support_ticket->id() . ' at ' . $base_url, 'attributes' => array('isPermaLink' => 'false'))); // The support ticket gets built and modules add to or modify $support_ticket->rss_elements // and $support_ticket->rss_namespaces. $build_mode = $display_mode; $build = support_ticket_view($support_ticket, $build_mode); unset($build['#theme']); if (!empty($support_ticket->rss_namespaces)) { $this->view->style_plugin->namespaces = array_merge($this->view->style_plugin->namespaces, $support_ticket->rss_namespaces); } elseif (function_exists('rdf_get_namespaces')) { // Merge RDF namespaces in the XML namespaces in case they are used // further in the RSS content. $xml_rdf_namespaces = array(); foreach (rdf_get_namespaces() as $prefix => $uri) { $xml_rdf_namespaces['xmlns:' . $prefix] = $uri; } $this->view->style_plugin->namespaces += $xml_rdf_namespaces; } if ($display_mode != 'title') { // We render support ticket contents. $description_build = $build; } $item = new \stdClass(); $item->description = $description_build; $item->title = $support_ticket->label(); $item->link = $support_ticket->link; // Provide a reference so that the render call in // template_preprocess_views_view_row_rss() can still access it. $item->elements =& $support_ticket->rss_elements; $item->stid = $support_ticket->id(); $build = array('#theme' => $this->themeFunctions(), '#view' => $this->view, '#options' => $this->options, '#row' => $item); return $build; }