@@ -36,6 +36,10 @@ class Server
3636 private const MIME_TYPE_DIRECTORY = 'directory ' ;
3737 private const QUERY_PARAM_HTTP_METHOD = 'http-method ' ;
3838
39+ private const NOTIFICATION_TYPE_CREATE = "Create " ;
40+ private const NOTIFICATION_TYPE_UPDATE = "Update " ;
41+ private const NOTIFICATION_TYPE_DELETE = "Delete " ;
42+
3943 /** @var string[] */
4044 private $ availableMethods = [
4145 'DELETE ' ,
@@ -333,7 +337,7 @@ private function handleSparqlUpdate(Response $response, string $path, $contents)
333337
334338 if ($ success ) {
335339 $ this ->removeLinkFromMetaFileFor ($ path );
336- $ this ->sendNotificationUpdate ($ path , " Update " );
340+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_UPDATE );
337341 }
338342 } catch (RdfException $ exception ) {
339343 $ response ->getBody ()->write (self ::ERROR_CAN_NOT_PARSE_FOR_PATCH );
@@ -484,7 +488,7 @@ private function handleN3Update(Response $response, string $path, $contents): Re
484488
485489 if ($ success ) {
486490 $ this ->removeLinkFromMetaFileFor ($ path );
487- $ this ->sendNotificationUpdate ($ path , " Update " );
491+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_UPDATE );
488492 }
489493 } catch (RdfException $ exception ) {
490494 $ response ->getBody ()->write (self ::ERROR_CAN_NOT_PARSE_FOR_PATCH );
@@ -534,7 +538,7 @@ private function handleCreateRequest(Response $response, string $path, $contents
534538 $ this ->removeLinkFromMetaFileFor ($ path );
535539 $ response = $ response ->withHeader ("Location " , $ this ->baseUrl . $ path );
536540 $ response = $ response ->withStatus (201 );
537- $ this ->sendNotificationUpdate ($ path , " Create " );
541+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_CREATE );
538542 } else {
539543 $ response = $ response ->withStatus (500 );
540544 }
@@ -568,7 +572,7 @@ private function handleCreateDirectoryRequest(Response $response, string $path):
568572 $ response = $ response ->withStatus ($ success ? 201 : 500 );
569573 if ($ success ) {
570574 $ this ->removeLinkFromMetaFileFor ($ path );
571- $ this ->sendNotificationUpdate ($ path , " Create " );
575+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_CREATE );
572576 }
573577 }
574578
@@ -582,7 +586,7 @@ private function sendNotificationUpdate($path, $type)
582586
583587 while ($ path !== "/ " ) {
584588 $ path = $ this ->parentPath ($ path );
585- $ this ->notifications ->send ($ baseUrl . $ path , " Update " ); // checkme: delete on a directory triggers update notifications on parents
589+ $ this ->notifications ->send ($ baseUrl . $ path , self :: NOTIFICATION_TYPE_UPDATE ); // checkme: delete on a directory triggers update notifications on parents
586590 }
587591 }
588592
@@ -602,15 +606,15 @@ private function handleDeleteRequest(Response $response, string $path, $contents
602606 } else {
603607 $ success = $ filesystem ->deleteDir ($ path );
604608 if ($ success ) {
605- $ this ->sendNotificationUpdate ($ path , " Delete " );
609+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_DELETE );
606610 }
607611
608612 $ status = $ success ? 204 : 500 ;
609613 }
610614 } else {
611615 $ success = $ filesystem ->delete ($ path );
612616 if ($ success ) {
613- $ this ->sendNotificationUpdate ($ path , " Delete " );
617+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_DELETE );
614618 }
615619 $ status = $ success ? 204 : 500 ;
616620 }
@@ -638,7 +642,7 @@ private function handleUpdateRequest(Response $response, string $path, string $c
638642 $ response = $ response ->withStatus ($ success ? 201 : 500 );
639643 if ($ success ) {
640644 $ this ->removeLinkFromMetaFileFor ($ path );
641- $ this ->sendNotificationUpdate ($ path , " Update " );
645+ $ this ->sendNotificationUpdate ($ path , self :: NOTIFICATION_TYPE_UPDATE );
642646 }
643647 }
644648
0 commit comments