Skip to content
Snippets Groups Projects

Refactored the views csv query plugin to introduced custom query and connection class.

Files
10
+ 12
29
@@ -2,7 +2,6 @@
namespace Drupal\views_csv_source\Event;
use Drupal\views\ViewExecutable;
use Symfony\Contracts\EventDispatcher\Event;
/**
@@ -15,50 +14,34 @@ class PreCacheEvent extends Event {
*/
const VIEWS_CSV_SOURCE_PRE_CACHE = 'views_csv_source.pre_cache';
/**
* The view executable.
*
* @var \Drupal\views\ViewExecutable
*/
protected $viewExecutable;
/**
* The Views CSV query result body.
*
* @var string
*/
protected $data;
/**
* Constructs the object.
*
* @param \Drupal\views\ViewExecutable $viewExecutable
* The view executable.
* @param string $cacheId
* The cache id.
* @param string $data
* The views CSV query result body.
*/
public function __construct(ViewExecutable $viewExecutable, string $data) {
$this->viewExecutable = $viewExecutable;
$this->data = $data;
public function __construct(protected string $cacheId, protected string $data) {
}
/**
* Get view executable.
*
* @return \Drupal\views\ViewExecutable
* Return view executable.
* @return string
* Return cache id.
*/
public function getViewExecutable(): ViewExecutable {
return $this->viewExecutable;
public function getCacheId(): string {
return $this->cacheId;
}
/**
* Get view result data.
* Get the data.
*
* @return string
* Return view data.
* Return data.
*/
public function getViewData(): string {
public function getData(): string {
return $this->data;
}
@@ -66,9 +49,9 @@ class PreCacheEvent extends Event {
* Set the data for this event.
*
* @param string $data
* The data to override view result data.
* The data to override result data.
*/
public function setViewData(string $data) {
public function setData(string $data) {
$this->data = $data;
}
Loading