You are here

function ViewsPhp::phpPostExecute in Views PHP 8

Same name in this branch
  1. 8 src/Plugin/views/filter/ViewsPhp.php \Drupal\views_php\Plugin\views\filter\ViewsPhp::phpPostExecute()
  2. 8 src/Plugin/views/sort/ViewsPhp.php \Drupal\views_php\Plugin\views\sort\ViewsPhp::phpPostExecute()
  3. 8 src/Plugin/views/field/ViewsPhp.php \Drupal\views_php\Plugin\views\field\ViewsPhp::phpPostExecute()

See also

views_php_views_post_execute()

File

src/Plugin/views/filter/ViewsPhp.php, line 97
Contains \Drupal\views_php\Plugin\views\filter\ViewsPhp.

Class

ViewsPhp
A handler to filter a view using PHP defined by the administrator.

Namespace

Drupal\views_php\Plugin\views\filter

Code

function phpPostExecute() {

  // Evaluate the PHP code.
  if (!empty($this->options['php_filter'])) {
    $function = create_function('$view, $handler, &$static, $row, $data', $this->options['php_filter'] . ';');
    ob_start();
    $normalized_row = new ViewsPhpNormalizedRow();
    foreach ($this->view->result as $i => $result) {
      foreach ($this->view->field as $id => $field) {
        $normalized_row->{$id} = $this->view->field[$id]
          ->theme($result);
      }
      if ($function($this->view, $this, $this->php_static_variable, $normalized_row, $result)) {
        unset($this->view->result[$i]);
      }
    }
    ob_end_clean();
  }
}