mirror of
https://github.com/nextcloud/documentation.git
synced 2026-03-27 13:38:39 +07:00
doc(ocs): Improved doc to expose Capabilities
I've added more context about where we create Capabilities and how to register it.
This commit is contained in:
@@ -698,6 +698,7 @@ How to expose Capabilities
|
||||
--------------------------
|
||||
|
||||
Imagine we take the same Todo app of the previous example and want to expose some capabilities to let clients know what they can expect.
|
||||
First, you should create your `Capabilities` in the `lib/AppInfo` folder :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
@@ -733,6 +734,33 @@ Now you have to add the correct return type annotation:
|
||||
|
||||
The capabilities will automatically appear in the generated specification.
|
||||
|
||||
You must register your `Capabilities` in the `lib/AppInfo/Application.php` file and you need to implement `IBootstrap` :
|
||||
|
||||
.. code-block:: php
|
||||
:emphasize-lines: 3
|
||||
|
||||
namespace OCA\Todo\AppInfo;
|
||||
|
||||
use OCP\AppFramework\Bootstrap\IBootstrap;
|
||||
|
||||
class Application extends App implements IBootstrap {
|
||||
public const APP_ID = 'todo';
|
||||
|
||||
public function __construct(array $urlParams = []) {
|
||||
parent::__construct(self::APP_ID, $urlParams);
|
||||
}
|
||||
|
||||
public function register(IRegistrationContext $context): void {
|
||||
// code
|
||||
|
||||
$context->registerCapability(Capabilities::class);
|
||||
}
|
||||
|
||||
public function boot(IBootContext $context): void {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Scopes
|
||||
------
|
||||
|
||||
|
||||
Reference in New Issue
Block a user