Changeset View
Changeset View
Standalone View
Standalone View
src/app/Backends/DAV.php
Show All 20 Lines | class DAV | ||||
protected $password; | protected $password; | ||||
protected $responseHeaders = []; | protected $responseHeaders = []; | ||||
/** | /** | ||||
* Object constructor | * Object constructor | ||||
*/ | */ | ||||
public function __construct($user, $password) | public function __construct($user, $password) | ||||
{ | { | ||||
$this->url = \config('dav.uri'); | $this->url = \config('services.dav.uri'); | ||||
$this->user = $user; | $this->user = $user; | ||||
$this->password = $password; | $this->password = $password; | ||||
} | } | ||||
/** | /** | ||||
* Discover DAV home (root) collection of a specified type. | * Discover DAV home (root) collection of a specified type. | ||||
* | * | ||||
* @param string $component Component to filter by (VEVENT, VTODO, VCARD) | * @param string $component Component to filter by (VEVENT, VTODO, VCARD) | ||||
▲ Show 20 Lines • Show All 141 Lines • ▼ Show 20 Lines | public function listFolders(string $component) | ||||
} | } | ||||
$folders = []; | $folders = []; | ||||
foreach ($response->getElementsByTagName('response') as $element) { | foreach ($response->getElementsByTagName('response') as $element) { | ||||
$folder = DAV\Folder::fromDomElement($element); | $folder = DAV\Folder::fromDomElement($element); | ||||
// Note: Addressbooks don't have 'type' specified | // Note: Addressbooks don't have 'type' specified | ||||
if (($component == self::TYPE_VCARD && in_array('addressbook', $folder->types)) | if (($component == self::TYPE_VCARD && in_array('addressbook', $folder->types)) | ||||
Lint: PSR12.ControlStructures.ControlStructureSpacing.FirstExpressionLine: The first expression of a multi-line control structure must be on the line after the opening… | |||||
|| in_array($component, $folder->components) | || in_array($component, $folder->components) | ||||
) { | ) { | ||||
$folders[] = $folder; | $folders[] = $folder; | ||||
} | } | ||||
} | } | ||||
return $folders; | return $folders; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 102 Lines • ▼ Show 20 Lines | public function search(string $location, string $component) | ||||
} | } | ||||
// TODO: Make filter an argument of this function to build all kind of queries. | // TODO: Make filter an argument of this function to build all kind of queries. | ||||
// It probably should be a separate object e.g. DAV\Filter. | // It probably should be a separate object e.g. DAV\Filter. | ||||
// TODO: List of object props to return should also be an argument, so we not only | // TODO: List of object props to return should also be an argument, so we not only | ||||
// could fetch "an index" but also any of object's data. | // could fetch "an index" but also any of object's data. | ||||
$body = '<?xml version="1.0" encoding="utf-8"?>' | $body = '<?xml version="1.0" encoding="utf-8"?>' | ||||
.' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | .' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | ||||
Lint: PSR12.Operators.OperatorSpacing.NoSpaceAfter Expected at least 1 space after "."; 0 found Lint: PSR12.Operators.OperatorSpacing.NoSpaceAfter: Expected at least 1 space after "."; 0 found | |||||
. '<d:prop>' | . '<d:prop>' | ||||
. '<d:getetag />' | . '<d:getetag />' | ||||
. '</d:prop>' | . '</d:prop>' | ||||
. ($filter ? "<c:filter>$filter</c:filter>" : '') | . ($filter ? "<c:filter>$filter</c:filter>" : '') | ||||
. '</c:' . $queries[$component] . '>'; | . '</c:' . $queries[$component] . '>'; | ||||
$response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | $response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | ||||
Show All 39 Lines | public function getObjects(string $location, string $component, array $hrefs = []) | ||||
$types = [ | $types = [ | ||||
self::TYPE_VEVENT => 'calendar-data', | self::TYPE_VEVENT => 'calendar-data', | ||||
self::TYPE_VTODO => 'calendar-data', | self::TYPE_VTODO => 'calendar-data', | ||||
self::TYPE_VCARD => 'address-data', | self::TYPE_VCARD => 'address-data', | ||||
]; | ]; | ||||
$body = '<?xml version="1.0" encoding="utf-8"?>' | $body = '<?xml version="1.0" encoding="utf-8"?>' | ||||
.' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | .' <c:' . $queries[$component] . ' xmlns:d="DAV:" xmlns:c="' . self::NAMESPACES[$component] . '">' | ||||
Lint: PSR12.Operators.OperatorSpacing.NoSpaceAfter Expected at least 1 space after "."; 0 found Lint: PSR12.Operators.OperatorSpacing.NoSpaceAfter: Expected at least 1 space after "."; 0 found | |||||
. '<d:prop>' | . '<d:prop>' | ||||
. '<d:getetag />' | . '<d:getetag />' | ||||
. '<c:' . $types[$component] . ' />' | . '<c:' . $types[$component] . ' />' | ||||
. '</d:prop>' | . '</d:prop>' | ||||
. $body | . $body | ||||
. '</c:' . $queries[$component] . '>'; | . '</c:' . $queries[$component] . '>'; | ||||
$response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | $response = $this->request($location, 'REPORT', $body, ['Depth' => 1, 'Prefer' => 'return-minimal']); | ||||
▲ Show 20 Lines • Show All 138 Lines • Show Last 20 Lines |
The first expression of a multi-line control structure must be on the line after the opening parenthesis