1
|
|
|
<?php |
2
|
|
|
namespace Dkd\PhpCmis\Bindings\Browser; |
3
|
|
|
|
4
|
|
|
/** |
5
|
|
|
* This file is part of php-cmis-client. |
6
|
|
|
* |
7
|
|
|
* (c) Sascha Egerer <[email protected]> |
8
|
|
|
* |
9
|
|
|
* For the full copyright and license information, please view the LICENSE |
10
|
|
|
* file that was distributed with this source code. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
use Dkd\PhpCmis\Constants; |
14
|
|
|
use Dkd\PhpCmis\Data\ExtensionDataInterface; |
15
|
|
|
use Dkd\PhpCmis\MultiFilingServiceInterface; |
16
|
|
|
|
17
|
|
|
/* |
18
|
|
|
* MultiFiling Service Browser Binding client. |
19
|
|
|
*/ |
20
|
|
|
class MultiFilingService extends AbstractBrowserBindingService implements MultiFilingServiceInterface |
21
|
|
|
{ |
22
|
|
|
/** |
23
|
|
|
* Adds an existing fileable non-folder object to a folder. |
24
|
|
|
* |
25
|
|
|
* @param string $repositoryId The identifier for the repository. |
26
|
|
|
* @param string $objectId The identifier for the object. |
27
|
|
|
* @param string $folderId The folder into which the object is to be filed. |
28
|
|
|
* @param boolean $allVersions Add all versions of the object to the folder if the repository |
29
|
|
|
* supports version-specific filing. Defaults to <code>true</code>. |
30
|
|
|
* @param ExtensionDataInterface|null $extension |
31
|
|
|
*/ |
32
|
|
|
public function addObjectToFolder( |
33
|
|
|
$repositoryId, |
34
|
|
|
$objectId, |
35
|
|
|
$folderId, |
36
|
|
|
$allVersions = true, |
37
|
|
|
ExtensionDataInterface $extension = null |
38
|
|
|
) |
39
|
|
|
{ |
40
|
|
|
$url = $this->getObjectUrl($repositoryId, $objectId); |
41
|
|
|
|
42
|
|
|
$queryArray = [ |
43
|
|
|
Constants::CONTROL_CMISACTION => Constants::CMISACTION_ADD_OBJECT_TO_FOLDER, |
44
|
|
|
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
45
|
|
|
Constants::PARAM_FOLDER_ID => $folderId, |
46
|
|
|
Constants::PARAM_ALL_VERSIONS => $allVersions ? 'true' : 'false', |
47
|
|
|
]; |
48
|
|
|
|
49
|
|
|
$this->post($url, $queryArray); |
50
|
|
|
} |
51
|
|
|
|
52
|
|
|
/** |
53
|
|
|
* Removes an existing fileable non-folder object from a folder. |
54
|
|
|
* |
55
|
|
|
* @param string $repositoryId The identifier for the repository. |
56
|
|
|
* @param string $objectId The identifier for the object. |
57
|
|
|
* @param string|null $folderId The folder from which the object is to be removed. |
58
|
|
|
* If no value is specified, then the repository MUST remove the object from all folders in which it is |
59
|
|
|
* currently filed. |
60
|
|
|
* @param ExtensionDataInterface|null $extension |
61
|
|
|
*/ |
62
|
|
View Code Duplication |
public function removeObjectFromFolder( |
|
|
|
|
63
|
|
|
$repositoryId, |
64
|
|
|
$objectId, |
65
|
|
|
$folderId = null, |
66
|
|
|
ExtensionDataInterface $extension = null |
67
|
|
|
) |
68
|
|
|
{ |
69
|
|
|
$url = $this->getObjectUrl($repositoryId, $objectId); |
70
|
|
|
|
71
|
|
|
$queryArray = [ |
72
|
|
|
Constants::CONTROL_CMISACTION => Constants::CMISACTION_REMOVE_OBJECT_FROM_FOLDER, |
73
|
|
|
Constants::PARAM_SUCCINCT => $this->getSuccinct() ? 'true' : 'false', |
74
|
|
|
Constants::PARAM_FOLDER_ID => $folderId, |
75
|
|
|
]; |
76
|
|
|
|
77
|
|
|
$this->post($url, $queryArray); |
78
|
|
|
} |
79
|
|
|
} |
80
|
|
|
|
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.
You can also find more detailed suggestions in the “Code” section of your repository.