Add ListingDefinition value object and its factory
[MAILPOET-2645]
This commit is contained in:
committed by
Jack Kitterhing
parent
521b473755
commit
fe16dd3ccc
@@ -94,6 +94,20 @@ class Handler {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function getListingDefinition(array $data): ListingDefinition {
|
||||||
|
$data = $this->processData($data);
|
||||||
|
return new ListingDefinition(
|
||||||
|
$data['group'],
|
||||||
|
$data['filter'] ?? [],
|
||||||
|
$data['search'],
|
||||||
|
$data['params'] ?? [],
|
||||||
|
$data['sort_by'],
|
||||||
|
$data['sort_order'],
|
||||||
|
$data['offset'],
|
||||||
|
$data['limit']
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
private function setSearch(ORMWrapper $model, array $data) {
|
private function setSearch(ORMWrapper $model, array $data) {
|
||||||
if (empty($data['search'])) {
|
if (empty($data['search'])) {
|
||||||
return;
|
return;
|
||||||
|
83
lib/Listing/ListingDefinition.php
Normal file
83
lib/Listing/ListingDefinition.php
Normal file
@@ -0,0 +1,83 @@
|
|||||||
|
<?php declare(strict_types = 1);
|
||||||
|
|
||||||
|
namespace MailPoet\Listing;
|
||||||
|
|
||||||
|
class ListingDefinition {
|
||||||
|
/** @var string|null */
|
||||||
|
private $group;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $filters;
|
||||||
|
|
||||||
|
/** @var string|null */
|
||||||
|
private $search;
|
||||||
|
|
||||||
|
/** @var array */
|
||||||
|
private $parameters;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $sortBy;
|
||||||
|
|
||||||
|
/** @var string */
|
||||||
|
private $sortOrder;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
private $offset;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
private $limit;
|
||||||
|
|
||||||
|
public function __construct(
|
||||||
|
string $group = null,
|
||||||
|
array $filters,
|
||||||
|
string $search = null,
|
||||||
|
array $parameters,
|
||||||
|
string $sortBy,
|
||||||
|
string $sortOrder,
|
||||||
|
int $offset,
|
||||||
|
int $limit
|
||||||
|
) {
|
||||||
|
$this->group = $group;
|
||||||
|
$this->filters = $filters;
|
||||||
|
$this->search = $search;
|
||||||
|
$this->parameters = $parameters;
|
||||||
|
$this->sortBy = $sortBy;
|
||||||
|
$this->sortOrder = $sortOrder;
|
||||||
|
$this->offset = $offset;
|
||||||
|
$this->limit = $limit;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return string|null */
|
||||||
|
public function getGroup() {
|
||||||
|
return $this->group;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getFilters(): array {
|
||||||
|
return $this->filters;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @return string|null */
|
||||||
|
public function getSearch() {
|
||||||
|
return $this->search;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getParameters(): array {
|
||||||
|
return $this->parameters;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSortBy(): string {
|
||||||
|
return $this->sortBy;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getSortOrder(): string {
|
||||||
|
return $this->sortOrder;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getOffset(): int {
|
||||||
|
return $this->offset;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function getLimit(): int {
|
||||||
|
return $this->limit;
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user