10000 [Feature] Add publishing of translation files · ollivr/laravel-json-api@7d1101a · GitHub
[go: up one dir, main page]

Skip to content

Commit 7d1101a

Browse files
committed
[Feature] Add publishing of translation files
1 parent 92c4b72 commit 7d1101a

File tree

3 files changed

+28
-19
lines changed

3 files changed

+28
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@
22
All notable changes to this project will be documented in this file. This project adheres to
33
[Semantic Versioning](http://semver.org/) and [this changelog format](http://keepachangelog.com/).
44

5+
## Unreleased
6+
7+
### Added
8+
- Translation files can now be published using the `vendor:publish` Artisan command.
9+
510
## [2.0.0-beta.3] - 2020-04-13
611

712
### Added

docs/features/async.md

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# Asynchronous Processing
22

3-
The JSON API specification
3+
The JSON API specification
44
[provides a recommendation](https://jsonapi.org/recommendations/#asynchronous-processing)
5-
for how APIs can implement long running processes. For example, if the operation to create a
6-
resource takes a long time, it is more appropriate to process the creation using
5+
for how APIs can implement long running processes. For example, if the operation to create a
6+
resource takes a long time, it is more appropriate to process the creation using
77
[Laravel's queue system](https://laravel.com/docs/queues)
88
and return a `202 Accepted` response to the client.
99

@@ -29,14 +29,14 @@ use Illuminate\Support\ServiceProvider;
2929

3030
class AppServiceProvider extends ServiceProvider
3131
{
32-
32+
3333
// ...
34-
34+
3535
public function register()
3636
{
3737
LaravelJsonApi::runMigrations();
3838
}
39-
39+
4040
}
4141
```
4242

@@ -45,7 +45,7 @@ class AppServiceProvider extends ServiceProvider
4545
If you want to customise the migrations, you can publish them as follows:
4646

4747
```bash
48-
$ php artisan vendor:publish --tag="json-api-migrations"
48+
$ php artisan vendor:publish --tag="json-api:migrations"
4949
```
5050

5151
If you do this, you **must not** call `LaravelJsonApi::runMigrations()` in your service provider.
@@ -76,7 +76,7 @@ use Neomerx\JsonApi\Schema\SchemaProvider;
7676
class Schema extends SchemaProvider
7777
{
7878
use AsyncSchema;
79-
79+
8080
// ...
8181
}
8282
```
@@ -112,7 +112,7 @@ class ProcessPodcast implements ShouldQueue
112112
{
113113

114114
use ClientDispatchable;
115-
115+
116116
// ...
117117
}
118118

@@ -130,7 +130,7 @@ means you can use any of the normal Laravel methods. The only difference is you
130130
`dispatch` method at the end of the chain so that you have access to the process that was stored
131131
and can be serialized into JSON by your API.
132132

133-
You can use this method of dispatching jobs in either
133+
You can use this method of dispatching jobs in either
134134
[Controller Hooks](../basics/controllers.md) or within
135135
[Resource Adapters](../basics/adapters.md), depending on your preference.
136136

@@ -190,9 +190,9 @@ class Adapter extends AbstractAdapter
190190
If a dispatched job creates a new resource (e.g. a new model), there is one additional step you will
191191
need to follow in the job's `handle` method. This is to link the stored process to the resource that was
192192
created as a result of the job completing successfully. The link must exist otherwise your API
193-
will not be able to inform a client of the location of the created resource once the job is complete.
193+
will not be able to inform a client of the location of the created resource once the job is complete.
194194

195-
You can easily create this link by calling the `didCreate` method that the `ClientDispatchable`
195+
You can easily create this link by calling the `didCreate` method that the `ClientDispatchable`
196196
trait adds to your job. For example:
197197

198198
```php
@@ -205,13 +205,13 @@ class ProcessPodcast implements ShouldQueue
205205
{
206206

207207
use ClientDispatchable;
208-
208+
209209
// ...
210-
210+
211211
public function handle()
212212
{
213213
// ...logic to process a podcast
214-
214+
215215
$this->didCreate($podcast);
216216
}
217217
}
@@ -272,11 +272,11 @@ This enables the following routes:
272272

273273
- `GET /podcasts/queue-jobs`: this lists all `queue-jobs` resources for the `podcasts`
274274
resource type.
275-
- `GET /podcasts/queue-jobs/<UUID>`: this retrieves a specific `queue-jobs` resource
275+
- `GET /podcasts/queue-jobs/<UUID>`: this retrieves a specific `queue-jobs` resource
276276
for the `podcasts` resource type.
277277

278278
The resource type `queue-jobs` is the name used in the JSON API's recommendation for
279-
asynchronous processing. If you want to use a resource type, then you can change this
279+
asynchronous processing. If you want to use a resource type, then you can change this
280280
by editing the `jobs.resource` config setting in your API's configuration file.
281281

282282
Note that we assume the resource id of a process is a valid UUID. If you use something
@@ -291,7 +291,7 @@ JsonApi::register('default')->withNamespace('Api')->routes(function ($api) {
291291
## HTTP Requests and Responses
292292

293293
Once you have followed the above instructions, you can now make HTTP requests and receive
294-
asynchronous process responses that following the
294+
asynchronous process responses that following the
295295
[JSON API recommendation.](https://jsonapi.org/recommendations/#asynchronous-processing)
296296

297297
For example, a request to create a podcast would receive the following response:

src/ServiceProvider.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,11 @@ public function boot(Router $router)
8080

8181
$this->publishes([
8282
__DIR__ . '/../database/migrations' => database_path('migrations'),
83-
], 'json-api-migrations');
83+
], 'json-api:migrations');
84+
85+
$this->publishes([
86+
__DIR__ . '/../resources/lang' => resource_path('lang/vendor/jsonapi'),
87+
], 'json-api:translations');
8488

8589
$this->commands([
8690
Console\Commands\MakeAdapter::class,

0 commit comments

Comments
 (0)
0