You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/extend/authorization.md
+4-4Lines changed: 4 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ Each of these is determined by unique criteria: in some cases a flag is sufficie
18
18
19
19
### How It Works
20
20
21
-
Authorization queries are made with 3 parameters, with logic contained in [`Flarum\User\Gate`](https://api.docs.flarum.org/php/master/flarum/user/gate):
21
+
Authorization queries are made with 3 parameters, with logic contained in [`Flarum\User\Gate`](https://api.docs.flarum.org/php/master/flarum/user/access/gate):
22
22
23
23
1. The actor: the user attempting to perform the action
24
24
2. The ability: a string representing the action the actor is attempting
@@ -195,7 +195,7 @@ return [
195
195
## Visibility Scoping
196
196
197
197
When a user visits the **All Discussions** page, we want to quickly show them the recent discussions that the user has access to.
198
-
We do this via the `whereVisibleTo` method, which is defined in `Flarum\Database\ScopeVisibilityTrait`, and available to [Eloquent models and queries](https://laravel.com/docs/6.x/queries) through [Eloquent scoping](https://laravel.com/docs/6.x/eloquent#local-scopes).
198
+
We do this via the `whereVisibleTo` method, which is defined in `Flarum\Database\ScopeVisibilityTrait`, and available to [Eloquent models and queries](https://laravel.com/docs/8.x/queries) through [Eloquent scoping](https://laravel.com/docs/8.x/eloquent#local-scopes).
199
199
For example:
200
200
201
201
```php
@@ -224,7 +224,7 @@ This call is handled by Flarum's general model visibility scoping system, which
224
224
225
225
The query will be run through all applicable scopers registered for the model of the query. Note that visibility scopers registered for a parent class (like `Flarum\Post\Post`) will also be applied to any child classes (like `Flarum\Post\CommentPost`).
226
226
227
-
Note that scopers don't need to return anything, but rather should perform in-place mutations on the [Eloquent query object](https://laravel.com/docs/6.x/queries).
227
+
Note that scopers don't need to return anything, but rather should perform in-place mutations on the [Eloquent query object](https://laravel.com/docs/8.x/queries).
228
228
229
229
### Custom Permission Strings
230
230
@@ -277,7 +277,7 @@ Think of calling `whereVisibleTo` with a custom ability as a way for extensions
277
277
278
278
### Custom Visibility Scoper Examples
279
279
280
-
Let's take a look at some examples from [Flarum Tags](https://github.com/flarum/tags/blob/master/src/Access/TagPolicy).
280
+
Let's take a look at some examples from [Flarum Tags](https://github.com/flarum/tags/blob/master/src/Access).
281
281
282
282
First, a scoper for the `Tag` model with the `view` ability:
Copy file name to clipboardExpand all lines: docs/extend/backend-events.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,6 +1,6 @@
1
1
# Backend Events
2
2
3
-
Often, an extension will want to react to some events occuring elsewhere in Flarum. For instance, we might want to increment a counter when a new discussion is posted, send a welcome email when a user logs in for the first time, or add tags to a discussion before saving it to the database. These events are known as **domain events**, and are broadcasted across the framework through [Laravel's event system](https://laravel.com/docs/6.x/events).
3
+
Often, an extension will want to react to some events occuring elsewhere in Flarum. For instance, we might want to increment a counter when a new discussion is posted, send a welcome email when a user logs in for the first time, or add tags to a discussion before saving it to the database. These events are known as **domain events**, and are broadcasted across the framework through [Laravel's event system](https://laravel.com/docs/8.x/events).
4
4
5
5
:::warning Old Event API
6
6
Historically, Flarum has used events for its extension API, emitting events like `GetDisplayName` or `ConfigureApiRoutes` to allow extensions to insert logic into various parts of Flarum. These events are gradually being phased out in favor of the declarative [extender system](start.md#extenders), and will be removed before stable. Domain events will not be removed.
@@ -43,7 +43,7 @@ class PostDeletedListener
43
43
}
44
44
```
45
45
46
-
As shown above, a listener class can be used instead of a callback. This allows you to [inject dependencies](https://laravel.com/docs/6.x/container) into your listener class via constructor parameters. In this example we resolve a translator instance, but we can inject anything we want/need.
46
+
As shown above, a listener class can be used instead of a callback. This allows you to [inject dependencies](https://laravel.com/docs/8.x/container) into your listener class via constructor parameters. In this example we resolve a translator instance, but we can inject anything we want/need.
47
47
48
48
You can also listen to multiple events at once via an event subscriber. This is useful for grouping common functionality; for instance, if you want to update some metadata on changes to posts:
Copy file name to clipboardExpand all lines: docs/extend/data.md
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -28,7 +28,7 @@ Migrations live inside a folder suitably named `migrations` in your extension's
28
28
29
29
### Migration Structure
30
30
31
-
In Flarum, migration files should **return an array** with two functions: `up` and `down`. The `up` function is used to add new tables, columns, or indexes to your database, while the `down` function should reverse these operations. These functions receive an instance of the [Laravel schema builder](https://laravel.com/docs/6.x/migrations#creating-tables) which you can use to alter the database schema:
31
+
In Flarum, migration files should **return an array** with two functions: `up` and `down`. The `up` function is used to add new tables, columns, or indexes to your database, while the `down` function should reverse these operations. These functions receive an instance of the [Laravel schema builder](https://laravel.com/docs/8.x/migrations#creating-tables) which you can use to alter the database schema:
32
32
33
33
```php
34
34
<?php
@@ -68,7 +68,7 @@ return Migration::createTable('users', function (Blueprint $table) {
68
68
});
69
69
```
70
70
71
-
When creating the table, you may use any of the schema builder's [column methods](https://laravel.com/docs/6.x/migrations#creating-columns) to define the table's columns.
71
+
When creating the table, you may use any of the schema builder's [column methods](https://laravel.com/docs/8.x/migrations#creating-columns) to define the table's columns.
A migration doesn't have to change database structure: you could use a migration to insert, update, or delete rows in a table. For instance, you could use migrations to assign [custom permissions](permissions.md) to groups other than Admin, or provide some initial data for a custom Eloquent model. Since you have access to the [Eloquent Schema Builder](https://laravel.com/docs/6.x/migrations#creating-tables), anything is possible (although of course, you should be extremely cautious and test your extension extensively).
104
+
A migration doesn't have to change database structure: you could use a migration to insert, update, or delete rows in a table. For instance, you could use migrations to assign [custom permissions](permissions.md) to groups other than Admin, or provide some initial data for a custom Eloquent model. Since you have access to the [Eloquent Schema Builder](https://laravel.com/docs/8.x/migrations#creating-tables), anything is possible (although of course, you should be extremely cautious and test your extension extensively).
105
105
106
106
Data migrations are the recommended way to specify default settings and permissions.
107
107
108
108
## Backend Models
109
109
110
-
With all your snazzy new database tables and columns, you're going to want a way to access the data in both the backend and the frontend. On the backend it's pretty straightforward – you just need to be familiar with [Eloquent](https://laravel.com/docs/6.x/eloquent).
110
+
With all your snazzy new database tables and columns, you're going to want a way to access the data in both the backend and the frontend. On the backend it's pretty straightforward – you just need to be familiar with [Eloquent](https://laravel.com/docs/8.x/eloquent).
111
111
112
112
### Adding New Models
113
113
@@ -141,7 +141,7 @@ return [
141
141
142
142
### Relationships
143
143
144
-
You can also add [relationships](https://laravel.com/docs/6.x/eloquent-relationships) to existing models using the `hasOne`, `belongsTo`, `hasMany`, `belongsToMany`and `relationship` methods on the `Model` extender. The first argument is the relationship name; the rest of the arguments are passed into the equivalent method on the model, so you can specify the related model name and optionally override table and key names:
144
+
You can also add [relationships](https://laravel.com/docs/8.x/eloquent-relationships) to existing models using the `hasOne`, `belongsTo`, `hasMany`, `belongsToMany`and `relationship` methods on the `Model` extender. The first argument is the relationship name; the rest of the arguments are passed into the equivalent method on the model, so you can specify the related model name and optionally override table and key names:
Copy file name to clipboardExpand all lines: docs/extend/i18n.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -125,7 +125,7 @@ This shows the basic translation method, with no bells or whistles attached. Bel
125
125
126
126
## Including Variables
127
127
128
-
You can include variables in translations. As an example, let's look at the code that creates the first item in Flarum's [search results dropdown](https://github.com/flarum/core/blob/master/js/forum/src/components/DiscussionsSearchSource.js). This button quotes the search query entered by the user — information that is passed to the translator along with the translation key, as an additional parameter:
128
+
You can include variables in translations. As an example, let's look at the code that creates the first item in Flarum's [search results dropdown](https://github.com/flarum/core/blob/master/js/src/forum/components/DiscussionsSearchSource.js). This button quotes the search query entered by the user — information that is passed to the translator along with the translation key, as an additional parameter:
This example is from the [Choose Tags modal](https://github.com/flarum/tags/blob/master/js/forum/src/components/TagDiscussionModal.js) of the Tags extension, where it tells the user how many more primary tags can be selected. Note that the `remaining` variable is passed to the translator **twice**. First, it appears as itself, to condition the pluralization of the word "tags". Then it appears again as the value of the `count` parameter, which the translator can use to insert that value in the translation.
184
+
This example is from the [Choose Tags modal](https://github.com/flarum/tags/blob/master/js/src/forum/components/TagDiscussionModal.js) of the Tags extension, where it tells the user how many more primary tags can be selected. Note that the `remaining` variable is passed to the translator **twice**. First, it appears as itself, to condition the pluralization of the word "tags". Then it appears again as the value of the `count` parameter, which the translator can use to insert that value in the translation.
185
185
186
186
When the `app.translator.transChoice()` method is called, the translator scans the translation for a variant that matches the sort of pluralization required by the value of the variable. These variants need to be listed serially — singular form first, then plural forms in order of increasing magnitude — and separated using the vertical line (`|`) character. Here's the English translation for the above code:
187
187
@@ -360,7 +360,7 @@ core:
360
360
361
361
It would very easy to change the translation for the header link without realizing that you're also changing things in the Log In modal — to say nothing of any extensions that might also be referencing that key! This sort of thing will be less likely to occur if you keep your reused translations in the `ref` namespace.
362
362
363
-
For this reason, any key references in the [core resources](https://github.com/flarum/lang-english/blob/master/locale/core.yml) **must** point to keys in the `core.ref` namespace. Key references in the resources for bundled extensions may point to either of two locations:
363
+
For this reason, any key references in the [core resources](https://github.com/flarum/core/blob/master/locale/core.yml) **must** point to keys in the `core.ref` namespace. Key references in the resources for bundled extensions may point to either of two locations:
364
364
365
365
- Extension-specific translations should go in the `ref` namespace of the extension's locale file.
366
366
@@ -402,7 +402,7 @@ Generally speaking, any displayed text that isn't supplied by a variable or the
402
402
403
403
Hardcoded text isn't the only way that code can create problems for localizers. Hardcoded syntax issues occur when the code forces words into a specific order that just won't work in other languages. They are generally the result of using two translations where just one would be more appropriate.
404
404
405
-
For an example, let's look at the line of text that's printed near the bottom of the [Log In modal](https://github.com/flarum/core/blob/master/js/forum/src/components/LogInModal.js):
405
+
For an example, let's look at the line of text that's printed near the bottom of the [Log In modal](https://github.com/flarum/core/blob/master/js/src/forum/components/LogInModal.js):
406
406
407
407
> Don't have an account? [Sign Up](#)
408
408
@@ -439,9 +439,9 @@ They are surprisingly easy to overlook. Of course, the need for pluralization su
439
439
> You like this.
440
440
> Toby and Franz like this.
441
441
442
-
And the situation is complicated by the presence of the second-person pronoun, since it always takes the plural form in English, even when we're talking about one person. That's why the `app.translator` call is so complicated in the code that outputs the above sentences for the [Likes extension](https://github.com/flarum/likes/blob/master/js/forum/src/addLikesList.js).
442
+
And the situation is complicated by the presence of the second-person pronoun, since it always takes the plural form in English, even when we're talking about one person. That's why the `app.translator` call is so complicated in the code that outputs the above sentences for the [Likes extension](https://github.com/flarum/likes/blob/master/js/src/forum/addLikesList.js).
443
443
444
-
Now look at this similar set of sentences, output by similar code in the [Mentions extension](https://github.com/flarum/mentions/blob/master/js/forum/src/addMentionedByList.js):
444
+
Now look at this similar set of sentences, output by similar code in the [Mentions extension](https://github.com/flarum/mentions/blob/master/js/src/forum/addMentionedByList.js):
Copy file name to clipboardExpand all lines: docs/extend/interactive-components.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,7 +68,7 @@ More information about methods available to override is available in our [API do
68
68
69
69
Since Flarum is a forum, we need tools for users to be able to create and edit posts and discussions. Flarum accomplishes this through the floating composer component.
70
70
71
-
The composer is managed by a global instance of [`ComposerState`]([https://api.docs.flarum.org/js/master/class/src/common/states/modalmanagerstate.js~modalmanagerstate), which is accessible via `app.composer` on the `forum` frontend. Its most important public methods are:
71
+
The composer is managed by a global instance of [`ComposerState`](https://api.docs.flarum.org/js/master/class/src/common/states/modalmanagerstate.js~modalmanagerstate), which is accessible via `app.composer` on the `forum` frontend. Its most important public methods are:
72
72
73
73
-`app.composer.load(componentClass, attrs)` will load in a new composer type. If a composer is already active, it will be replaced.
74
74
-`app.composer.show()` will show the composer if it is currently hidden.
@@ -84,5 +84,5 @@ This is done by splitting code for each usage into a subclass of `flarum/forum/c
84
84
### Composer Editor
85
85
86
86
The actual editor is yet another component, [`flarum/common/components/TextEditor`](https://api.docs.flarum.org/js/master/class/src/common/components/texteditor.js~texteditor).
87
-
Its state can be programatically accessed via an "editor driver", which implements [`EditorDriverInterface`](https://github.com/flarum/core/blob/7d79912d3651f49e045302946b99a562f791b730/js/src/common/utils/EditorDriverInterface.ts).
87
+
Its state can be programatically accessed via an "editor driver", which implements [`EditorDriverInterface`](https://github.com/flarum/core/blob/master/js/src/common/utils/EditorDriverInterface.ts).
88
88
This is globally available for the current composer via `app.composer.editor`, and allows extensions to programatically read, insert, and modify the current contents, selections, and cursor position of the active composer's text editor.
Copy file name to clipboardExpand all lines: docs/extend/notifications.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -99,7 +99,7 @@ In addition to registering our notification to send by email, if we actually wan
99
99
To do this, your notification blueprint should implement [`Flarum\Notification\MailableInterface`](https://api.docs.flarum.org/php/master/flarum/notification/mailableinterface) in addition to [`Flarum\Notification\Blueprint\BlueprintInterface`](https://api.docs.flarum.org/php/master/flarum/notification/blueprint/blueprintinterface).
100
100
This comes with 2 additional methods:
101
101
102
-
-`getEmailView()` should return an array of email type to [Blade View](https://laravel.com/docs/6.x/blade) names. The namespaces for these views must [first be registered](routes.md#views). These will be used to generate the body of the email.
102
+
-`getEmailView()` should return an array of email type to [Blade View](https://laravel.com/docs/8.x/blade) names. The namespaces for these views must [first be registered](routes.md#views). These will be used to generate the body of the email.
103
103
-`getEmailSubject(TranslatorInterface $translator)` should return a string for the email subject. An instance of the translator is passed in to enable translated notification emails.
104
104
105
105
Let's take a look at an example from [Flarum Mentions](https://github.com/flarum/mentions/blob/master/src/Notification/PostMentionedBlueprint.php)
Copy file name to clipboardExpand all lines: docs/extend/routes.md
+2-2Lines changed: 2 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -59,7 +59,7 @@ class HelloWorldController implements RequestHandlerInterface
59
59
}
60
60
```
61
61
62
-
Controllers are resolved from the [container](https://laravel.com/docs/6.x/container) so you can inject dependencies into their constructors.
62
+
Controllers are resolved from the [container](https://laravel.com/docs/8.x/container) so you can inject dependencies into their constructors.
63
63
64
64
:::tip What are Controllers?
65
65
The `handle` method of a Controller is the code that runs when someone visits your route (or sends data to it via a form submission). Generally speaking, Controller implementations follow the pattern:
You can inject Laravel's [View](https://laravel.com/docs/6.x/views) factory into your controller. This will allow you to render a [Blade template](https://laravel.com/docs/6.x/blade) into your controller's response.
100
+
You can inject Laravel's [View](https://laravel.com/docs/8.x/views) factory into your controller. This will allow you to render a [Blade template](https://laravel.com/docs/8.x/blade) into your controller's response.
101
101
102
102
First, you will need to tell the view factory where it can find your extension's view files by adding a `View` extender to `extend.php`:
0 commit comments