Skip to content

Commit 6d5e6b6

Browse files
committed
Document acp search providers
1 parent cea25cc commit 6d5e6b6

6 files changed

Lines changed: 131 additions & 0 deletions

File tree

‎docs/migration/wsc62/deprecations_removals.md‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,12 @@ With version 6.3, we have deprecated certain components and removed several othe
3030
- `wcf\data\user\UserBirthdayAction`
3131
- `blog\data\blog\user\SubscriberAction`
3232
- `wcf\acp\page\AbstractCategoryNodeTreeViewPage`
33+
- `wcf\data\acp\search\provider\ACPSearchProvider` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
34+
- `wcf\data\acp\search\provider\ACPSearchProviderAction` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
35+
- `wcf\data\acp\search\provider\ACPSearchProviderEditor` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
36+
- `wcf\data\acp\search\provider\ACPSearchProviderList` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
37+
- `wcf\system\cache\builder\ACPSearchProviderCacheBuilder` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
38+
- `wcf\system\package\plugin\ACPSearchProviderPackageInstallationPlugin` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
3339

3440
#### Methods
3541

@@ -357,6 +363,8 @@ With version 6.3, we have deprecated certain components and removed several othe
357363
- `wbb\data\thread\ThreadAction::validateGetSimilarThreads()`
358364
- `wbb\data\thread\ThreadAction::getSimilarThreads()`
359365
- `wbb\data\thread\ThreadAction::updateSimilarThreads()`
366+
- `wcf\data\acp\search\provider\ACPSearchProviderAction::getSearchResultList()` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
367+
- `wcf\data\acp\search\provider\ACPSearchProviderAction::validateGetSearchResultList()` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))
360368
- `wcf\data\like\ViewableLike::setUserProfile()`
361369
- `wcf\data\like\ViewableLike::getObjectTypeName()`
362370
- `filebase\data\file\File::setFileContent()`
@@ -456,3 +464,4 @@ With version 6.3, we have deprecated certain components and removed several othe
456464
- `WoltLabSuite/Filebase/Ui/Review/SortHandler`
457465
- `WoltLabSuite/Filebase/Ui/Review/VersionFilter`
458466
- `WoltLabSuite/Core/Ui/Like/Handler`
467+
- `WCF.ACP.Search` ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681))

‎docs/migration/wsc62/php.md‎

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,61 @@ class ArticleCategoryType extends AbstractCategoryType
5757
This is used by the “Add Child Category” interaction in the node tree view to allow users to directly create a child category for a given node.
5858

5959
Custom subclasses of `CategoryAddFormBuilderForm` do not require any changes for this to work.
60+
61+
## ACP Search Providers
62+
63+
The registration of ACP search providers has been overhauled ([WoltLab/WCF#6681](https://github.com/WoltLab/WCF/issues/6681)).
64+
65+
### Registering Providers Through an Event
66+
67+
Providers are now registered through the PSR-14 event `wcf\event\acp\search\provider\ProviderCollecting`.
68+
See the [ACP search providers](../../package/acp-search-providers.md) page for the full API reference.
69+
The `acpSearchProvider` package installation plugin and the underlying database object remain available but are deprecated and should no longer be used for new providers.
70+
71+
A bootstrap script registers an event listener that adds the provider instances:
72+
73+
```php
74+
EventHandler::getInstance()->register(
75+
\wcf\event\acp\search\provider\ProviderCollecting::class,
76+
static function (\wcf\event\acp\search\provider\ProviderCollecting $event) {
77+
$event->register(
78+
'com.example.myProvider',
79+
new \example\system\search\acp\MyAcpSearchResultProvider()
80+
);
81+
}
82+
);
83+
```
84+
85+
The provider class must still implement `wcf\system\search\acp\IACPSearchResultProvider`.
86+
The first argument of `register()` is the textual identifier that is also used as the language item key for the result group title (`wcf.acp.search.provider.{providerName}`).
87+
88+
Providers are sorted by their translated label; the explicit `showOrder` from the deprecated PIP is no longer evaluated for event-registered providers.
89+
90+
Providers that are still registered through the deprecated `acpSearchProvider` PIP continue to work and are merged with the event-registered providers, but they are shadowed by event-registered providers using the same `providerName`.
91+
92+
### Searching Through the RPC API
93+
94+
The legacy AJAX action `wcf\data\acp\search\provider\ACPSearchProviderAction::getSearchResultList()` has been replaced by the RPC endpoint `GET /core/acp/search`.
95+
96+
| Parameter | Type | Description |
97+
|-----------|------|-------------|
98+
| `query` | `non-empty-string` | The search query. |
99+
| `provider` | `string` (optional) | Restrict the search to a single provider identified by its `providerName`. |
100+
101+
The response payload has the following shape:
102+
103+
```json
104+
{
105+
"results": [
106+
{
107+
"title": "Translated provider title",
108+
"items": [
109+
{ "title": "…", "link": "…", "subtitle": "…" }
110+
]
111+
}
112+
]
113+
}
114+
```
115+
116+
The endpoint requires the `admin.general.canUseAcp` permission.
117+
Each registered provider remains responsible for enforcing its own admin permissions inside `IACPSearchResultProvider::search()`.
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# ACP Search Providers
2+
3+
The API for the ACP search providers allows you to add your own provider for the admin panel search.
4+
5+
Since WoltLab Suite 6.3 you can attach an event listener to the `wcf\event\acp\search\provider\ProviderCollecting` event inside a [bootstrap script](../package/bootstrap-scripts.md) to lazily register your ACP search providers.
6+
7+
The `register` method of the event expects the following parameters:
8+
9+
| Name | Type | Description |
10+
|------|------|-------------|
11+
| `$providerName` | string | Identifier of the provider; must be unique. Also used as the language item key for the result group title (`wcf.acp.search.provider.{$providerName}`). |
12+
| `$provider` | IACPSearchResultProvider | Provider instance that implements `wcf\system\search\acp\IACPSearchResultProvider`. |
13+
14+
Providers are sorted by their translated label.
15+
16+
The provider class must implement `wcf\system\search\acp\IACPSearchResultProvider` and return a list of `wcf\system\search\acp\ACPSearchResult` instances from its `search()` method. The provider itself is responsible for enforcing the relevant admin permissions.
17+
18+
Example:
19+
20+
```php
21+
<?php
22+
23+
use wcf\event\acp\search\provider\ProviderCollecting;
24+
use wcf\system\event\EventHandler;
25+
use wcf\system\search\acp\ACPSearchResult;
26+
use wcf\system\search\acp\IACPSearchResultProvider;
27+
use wcf\system\WCF;
28+
29+
final class FooACPSearchResultProvider implements IACPSearchResultProvider
30+
{
31+
#[\Override]
32+
public function search(string $query)
33+
{
34+
if (!WCF::getSession()->hasPermission('admin.foo.canManageFoo')) {
35+
return [];
36+
}
37+
38+
$results = [];
39+
// collect matching items and append:
40+
// $results[] = new ACPSearchResult($title, $link, $subtitle);
41+
42+
return $results;
43+
}
44+
}
45+
46+
return static function (): void {
47+
EventHandler::getInstance()->register(ProviderCollecting::class, static function (ProviderCollecting $event) {
48+
$event->register(
49+
'com.woltlab.foo.bar',
50+
new FooACPSearchResultProvider()
51+
);
52+
});
53+
};
54+
```
55+
56+
The language item `wcf.acp.search.provider.com.woltlab.foo.bar` must be provided through the [language package installation plugin](pip/language.md) so that the provider appears in the search type dropdown and as the heading of its result group.
57+
58+
The legacy [`acpSearchProvider` package installation plugin](pip/acp-search-provider.md) and the associated database object `wcf\data\acp\search\provider\ACPSearchProvider` are deprecated as of WoltLab Suite 6.3. Providers that are still registered through the deprecated PIP keep working but are shadowed by event-registered providers using the same `providerName`.

‎docs/package/pip/acp-search-provider.md‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# ACP Search Provider Package Installation Plugin
22

3+
!!! warning "Deprecated in WoltLab Suite 6.3"
4+
Use the [ACP search providers](../acp-search-providers.md) API based on the PSR-14 event `wcf\event\acp\search\provider\ProviderCollecting` to register ACP search providers.
5+
See the [migration guide](../../migration/wsc62/php.md#acp-search-providers) for details.
6+
37
Registers data provider for the admin panel search.
48

59
## Components

‎docs/php/api/events.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,7 @@ final class ValueDumpListener
264264
| `wcf\event\acp\dashboard\box\PHPExtensionCollecting` | Requests the collection of PHP extensions for the system info ACP dashboard box. |
265265
| `wcf\event\acp\dashboard\box\StatusMessageCollecting` | Requests the collection of status messages for the status message dashboard box. |
266266
| `wcf\event\acp\menu\item\ItemCollecting` | Requests the collection of acp menu items. |
267+
| `wcf\event\acp\search\provider\ProviderCollecting` | Requests the collection of acp search providers. |
267268
| `wcf\event\cache\CacheCleared` | Indicates that a full cache clear was performed. |
268269
| `wcf\event\comment\CommentCreated` | Indicates that a new comment has been created. |
269270
| `wcf\event\comment\CommentPublished` | Indicates that a new comment has been published. This can happen directly when a comment is created or be delayed if a comment has first been checked and approved by a moderator. |

‎mkdocs.yml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ nav:
150150
- 'userOption': 'package/pip/user-option.md'
151151
- 'userProfileMenu': 'package/pip/user-profile-menu.md'
152152
- 'ACP Menu Items': 'package/acp-menu-items.md'
153+
- 'ACP Search Providers': 'package/acp-search-providers.md'
153154
- 'Database PHP API': 'package/database-php-api.md'
154155

155156
- 'Migration':

0 commit comments

Comments
 (0)