Seperate query classes from xml classes to allow specifying more information in the query

This commit is contained in:
Robin Appelman 2018-01-25 14:48:02 +01:00
commit 5ad4d24b89
17 changed files with 509 additions and 112 deletions

View file

@ -28,22 +28,7 @@ use SearchDAV\DAV\SearchPlugin;
/**
* The limit and offset of a search query
*/
class Limit implements XmlDeserializable {
/**
* @var integer
*
* The maximum number of results to be returned
*
* If set to 0 then no limit should be imposed
*/
public $maxResults = 0;
/**
* @var integer
*
* The index of the first result to be returned (offset)
*/
public $firstResult = 0;
class Limit extends \SearchDAV\Query\Limit implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
$limit = new self();

View file

@ -25,24 +25,7 @@ namespace SearchDAV\XML;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class Literal implements XmlDeserializable {
/**
* @var string|boolean|\DateTime|integer
*
* The value of the literal
*/
public $value;
/**
* Literal constructor.
*
* @param bool|\DateTime|int|string $value
*/
public function __construct($value = '') {
$this->value = $value;
}
class Literal extends \SearchDAV\Query\Literal implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
$literal = new self();

View file

@ -21,28 +21,14 @@
namespace SearchDAV\XML;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class Operator implements XmlDeserializable {
const OPERATION_AND = '{DAV:}and';
const OPERATION_OR = '{DAV:}or';
const OPERATION_NOT = '{DAV:}not';
const OPERATION_EQUAL = '{DAV:}eq';
const OPERATION_LESS_THAN = '{DAV:}lt';
const OPERATION_LESS_OR_EQUAL_THAN = '{DAV:}lte';
const OPERATION_GREATER_THAN = '{DAV:}gt';
const OPERATION_GREATER_OR_EQUAL_THAN = '{DAV:}gte';
const OPERATION_IS_COLLECTION = '{DAV:}is-collection';
const OPERATION_IS_DEFINED = '{DAV:}is-defined';
const OPERATION_IS_LIKE = '{DAV:}like';
const OPERATION_CONTAINS = '{DAV:}contains';
/**
* @var string
*
* The type of operation, one of the Operation::OPERATION_* constants
* The type of operation, one of the Operator::OPERATION_* constants
*/
public $type;
/**
@ -69,7 +55,6 @@ class Operator implements XmlDeserializable {
$this->arguments = $arguments;
}
static function xmlDeserialize(Reader $reader) {
$operator = new self();

View file

@ -26,9 +26,6 @@ use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class Order implements XmlDeserializable {
const ASC = 'ascending';
const DESC = 'descending';
/**
* @var string
*
@ -48,7 +45,7 @@ class Order implements XmlDeserializable {
* @param string $property
* @param string $order
*/
public function __construct($property = '', $order = self::ASC) {
public function __construct($property = '', $order = \SearchDAV\Query\Order::ASC) {
$this->property = $property;
$this->order = $order;
}
@ -58,7 +55,7 @@ class Order implements XmlDeserializable {
$childs = \Sabre\Xml\Deserializer\keyValue($reader);
$order->order = array_key_exists('{DAV:}descending', $childs) ? self::DESC : self::ASC;
$order->order = array_key_exists('{DAV:}descending', $childs) ? \SearchDAV\Query\Order::DESC : \SearchDAV\Query\Order::ASC;
$order->property = $childs['{DAV:}prop'][0];
return $order;

View file

@ -21,46 +21,10 @@
namespace SearchDAV\XML;
use Sabre\Xml\Reader;
use Sabre\Xml\XmlDeserializable;
class Scope implements XmlDeserializable {
/**
* @var string
*
* The scope of the search, either as absolute uri or as a path relative to the
* search arbiter.
*/
public $href;
/**
* @var string|int 0, 1 or 'infinite'
*
* How deep the search query should be with 0 being only the scope itself,
* 1 being all direct child entries of the scope and infinite being all entries
* in the scope collection at any depth.
*/
public $depth;
/**
* @var string|null
*
* the path of the search scope relative to the dav server, or null if the scope is outside the dav server
*/
public $path;
/**
* @param string $href
* @param int|string $depth
* @param string|null $path
*/
public function __construct($href = '', $depth = 1, $path = null) {
$this->href = $href;
$this->depth = $depth;
$this->path = $path;
}
class Scope extends \SearchDAV\Query\Scope implements XmlDeserializable {
static function xmlDeserialize(Reader $reader) {
$scope = new self();