blob: f3c5ea5c033ba87594bfdc16205e20df6ccb1794 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
|
<?php
declare(strict_types=1);
namespace Sabre\DAV;
/**
* This class represents a MKCOL operation.
*
* MKCOL creates a new collection. MKCOL comes in two flavours:
*
* 1. MKCOL with no body, signifies the creation of a simple collection.
* 2. MKCOL with a request body. This can create a collection with a specific
* resource type, and a set of properties that should be set on the new
* collection. This can be used to create caldav calendars, carddav address
* books, etc.
*
* Property updates must always be atomic. This means that a property update
* must either completely succeed, or completely fail.
*
* @copyright Copyright (C) fruux GmbH (https://fruux.com/)
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
class MkCol extends PropPatch
{
/**
* A list of resource-types in clark-notation.
*
* @var array
*/
protected $resourceType;
/**
* Creates the MKCOL object.
*
* @param string[] $resourceType list of resourcetype values
* @param array $mutations list of new properties values
*/
public function __construct(array $resourceType, array $mutations)
{
$this->resourceType = $resourceType;
parent::__construct($mutations);
}
/**
* Returns the resourcetype of the new collection.
*
* @return string[]
*/
public function getResourceType()
{
return $this->resourceType;
}
/**
* Returns true or false if the MKCOL operation has at least the specified
* resource type.
*
* If the resourcetype is specified as an array, all resourcetypes are
* checked.
*
* @param string|string[] $resourceType
*
* @return bool
*/
public function hasResourceType($resourceType)
{
return 0 === count(array_diff((array) $resourceType, $this->resourceType));
}
}
|