mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2026-04-09 14:33:44 +00:00
Implements controllers for locking and unlocking with the webdav protocol (wip)
This commit is contained in:
43
src/Bundle/ChillDocStoreBundle/Dav/Utils/LockTokenParser.php
Normal file
43
src/Bundle/ChillDocStoreBundle/Dav/Utils/LockTokenParser.php
Normal file
@@ -0,0 +1,43 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
/*
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Chill\DocStoreBundle\Dav\Utils;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
final readonly class LockTokenParser
|
||||
{
|
||||
public function parseLockToken(Request $request): ?string
|
||||
{
|
||||
$token = $request->headers->get('lock-token');
|
||||
|
||||
if (null === $token) {
|
||||
return null;
|
||||
}
|
||||
if (str_starts_with($token, '"')) {
|
||||
$token = substr($token, 1, -1);
|
||||
}
|
||||
|
||||
if (str_starts_with($token, '<')) {
|
||||
$token = substr($token, 1);
|
||||
}
|
||||
|
||||
if (str_ends_with($token, '>')) {
|
||||
$token = substr($token, 0, -1);
|
||||
}
|
||||
|
||||
if (str_ends_with($token, '"')) {
|
||||
$token = substr($token, 1, -1);
|
||||
}
|
||||
|
||||
return $token;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user