Skip to content

Commit 9b02171

Browse files
authored
Merge pull request #5 from nstack-io/develop
Develop
2 parents a4d612f + f531a89 commit 9b02171

File tree

5 files changed

+298
-12
lines changed

5 files changed

+298
-12
lines changed

README.md

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,26 +15,38 @@ To install this package you will need:
1515

1616
* PHP 7.1+
1717

18-
Run
18+
Run
1919

2020
`composer require nstack/laravel-sdk`
2121

2222
or setup in composer.json
2323

2424
`nstack/laravel-sdk: 1.0.x`
2525

26+
In `config/app.php` (Laravel) or `bootstrap/app.php` (Lumen) you should replace Laravel's translation service provider
27+
28+
```php
29+
Illuminate\Translation\TranslationServiceProvider::class,
30+
```
31+
32+
by the one included in this package:
33+
34+
```php
35+
NStack\ServiceProvider::class
36+
```
2637

2738
Setup in config/app.php
2839

2940
```php
3041

31-
'providers' =>
42+
'providers' =>
3243
[
3344
....
45+
// Illuminate\Translation\TranslationServiceProvider::class
3446
NStack\ServiceProvider::class
3547
]
3648

37-
'aliases' =>
49+
'aliases' =>
3850
[
3951
....
4052
'NStack' => NStack\Facade::class,
@@ -57,12 +69,20 @@ You can now call via facade, eg:
5769
\NStack::getContinentsClient()->index()
5870
````
5971

60-
or via globa func
72+
or via global function
6173

6274
```php
6375
nstack()->getContinentsClient()->index()
6476
```
6577

78+
79+
or via integration with `trans()` [helper](https://laravel.com/docs/5.8/helpers#method-trans)
80+
81+
```php
82+
echo trans('messages.welcome');
83+
```
84+
85+
6686
All the basic fuctionality can be found in the php-sdk
6787

6888
## Features
@@ -72,7 +92,9 @@ All the basic fuctionality can be found in the php-sdk
7292

7393
[Link here](https://github.com/nstack-io/php-sdk)
7494

95+
All PHP functionality can be found
7596

97+
[Link](https://github.com/nstack-io/php-sdk)
7698

7799
## 🏆 Credits
78100

composer.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
],
1717
"require": {
1818
"php": "^7.1",
19-
"nstack/php-sdk": "1.0.x",
20-
"laravel/framework": "5.4.*||5.5.*||5.6.*||5.7.*||5.8.*"
19+
"nstack/php-sdk": "1.0.*",
20+
"illuminate/translation": "5.4.*|5.5.*|5.6.*|5.7.*|5.8.*|^6.0"
2121
},
2222
"require-dev": {
2323
"phpunit/phpunit": "~5.7",
@@ -33,4 +33,4 @@
3333
"src/Helpers.php"
3434
]
3535
}
36-
}
36+
}

config/nstack.php

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,8 @@
55
'master_key' => null,
66
'base_url' => 'https://nstack.io',
77
'version' => 'v2',
8-
];
8+
'platform' => 'backend',
9+
'cacheTime' => 600,
10+
'maxNetworkRetries' => 3,
11+
'retryNetworkAfterSec' => 10,
12+
];

src/ServiceProvider.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,14 @@
22

33
namespace NStack;
44

5-
use Illuminate\Support\ServiceProvider as IlluminateServiceProvider;
5+
use Illuminate\Support\Str;
6+
use Illuminate\Translation\TranslationServiceProvider;
7+
use NStack\Translation\NStackLoader;
68

79
/**
810
* Class ServiceProvider.
911
*/
10-
class ServiceProvider extends IlluminateServiceProvider
12+
class ServiceProvider extends TranslationServiceProvider
1113
{
1214
/**
1315
* boot
@@ -16,7 +18,9 @@ class ServiceProvider extends IlluminateServiceProvider
1618
*/
1719
public function boot()
1820
{
19-
$this->publishGroups();
21+
if (!Str::contains($this->app->version(), 'Lumen')) {
22+
$this->publishGroups();
23+
}
2024
}
2125

2226
/**
@@ -28,6 +32,7 @@ public function register()
2832
{
2933
$this->registerManager();
3034
$this->setupBindings();
35+
parent::register();
3136
}
3237

3338
/**
@@ -55,6 +60,17 @@ protected function setupBindings()
5560
});
5661
}
5762

63+
/**
64+
* {@inheritDoc}
65+
* @see \Illuminate\Translation\TranslationServiceProvider::registerLoader()
66+
*/
67+
protected function registerLoader()
68+
{
69+
$this->app->singleton('translation.loader', function ($app) {
70+
return new NStackLoader($app['files'], $app['path.lang'], $app->get('nstack'));
71+
});
72+
}
73+
5874
/**
5975
* Register assets manager.
6076
*
@@ -71,4 +87,4 @@ public function registerManager()
7187
return new NStack($config);
7288
});
7389
}
74-
}
90+
}

0 commit comments

Comments
 (0)