1212use NCU \Security \Signature \Exceptions \SignatoryException ;
1313use OC \OCM \OCMSignatoryManager ;
1414use OCP \Capabilities \ICapability ;
15+ use OCP \Capabilities \IInitialStateExcludedCapability ;
1516use OCP \IAppConfig ;
1617use OCP \IURLGenerator ;
1718use OCP \OCM \Exceptions \OCMArgumentException ;
1819use OCP \OCM \IOCMProvider ;
1920use Psr \Log \LoggerInterface ;
2021
21- class Capabilities implements ICapability {
22+ class Capabilities implements ICapability, IInitialStateExcludedCapability {
2223 public const API_VERSION = '1.1 ' ; // informative, real version.
2324
2425 public function __construct (
@@ -54,15 +55,13 @@ public function __construct(
5455 */
5556 public function getCapabilities () {
5657 $ url = $ this ->urlGenerator ->linkToRouteAbsolute ('cloud_federation_api.requesthandlercontroller.addShare ' );
57-
58- $ this ->provider ->setEnabled (true );
59- $ this ->provider ->setApiVersion (self ::API_VERSION );
60-
6158 $ pos = strrpos ($ url , '/ ' );
6259 if ($ pos === false ) {
63- throw new OCMArgumentException ('generated route should contains a slash character ' );
60+ throw new OCMArgumentException ('generated route should contain a slash character ' );
6461 }
6562
63+ $ this ->provider ->setEnabled (true );
64+ $ this ->provider ->setApiVersion (self ::API_VERSION );
6665 $ this ->provider ->setEndPoint (substr ($ url , 0 , $ pos ));
6766
6867 $ resource = $ this ->provider ->createNewResourceType ();
@@ -87,6 +86,6 @@ public function getCapabilities() {
8786 $ this ->logger ->warning ('cannot generate local signatory ' , ['exception ' => $ e ]);
8887 }
8988
90- return ['ocm ' => json_decode ( json_encode ( $ this ->provider ->jsonSerialize ()), true )];
89+ return ['ocm ' => $ this ->provider ->jsonSerialize ()];
9190 }
9291}
0 commit comments