-
-
Notifications
You must be signed in to change notification settings - Fork 512
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-locale-cookie
- Loading branch information
Showing
21 changed files
with
593 additions
and
356 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: run-tests | ||
|
||
on: | ||
push: | ||
branches: [master] | ||
pull_request: | ||
branches: [master] | ||
|
||
jobs: | ||
test: | ||
runs-on: ${{ matrix.os }} | ||
strategy: | ||
fail-fast: true | ||
matrix: | ||
os: [ubuntu-latest] | ||
php: [8.4, 8.3, 8.2] | ||
laravel: [11.*, 10.*] | ||
stability: [prefer-lowest, prefer-stable] | ||
include: | ||
- laravel: 11.* | ||
testbench: 9.* | ||
- laravel: 10.* | ||
testbench: 8.* | ||
|
||
name: P${{ matrix.php }} - L${{ matrix.laravel }} - ${{ matrix.stability }} - ${{ matrix.os }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: ${{ matrix.php }} | ||
extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick, fileinfo | ||
coverage: none | ||
|
||
- name: Setup problem matchers | ||
run: | | ||
echo "::add-matcher::${{ runner.tool_cache }}/php.json" | ||
echo "::add-matcher::${{ runner.tool_cache }}/phpunit.json" | ||
- name: Install dependencies | ||
run: | | ||
composer require "laravel/framework:${{ matrix.laravel }}" "nesbot/carbon:^2.64" "orchestra/testbench-browser-kit:${{ matrix.testbench }}" --no-interaction --no-update | ||
composer update --${{ matrix.stability }} --prefer-dist --no-interaction | ||
- name: Execute tests | ||
run: vendor/bin/phpunit |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ composer.lock | |
composer.phar | ||
Thumbs.db | ||
phpunit.xml | ||
.phpunit.cache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
## From v1 to v2 | ||
This package now uses [dependency injection](https://laravel.com/docs/container#introduction) to retrieve dependencies from the container. | ||
|
||
This modification is a breaking change, especially if you had made extensions to the `__construct` method within the `Mcamara\LaravelLocalization\LaravelLocalization` class. | ||
You may now use depdency injection in your own implementation and forward the dependencies to the parent constructor. | ||
```php | ||
use Mcamara\LaravelLocalization\LaravelLocalization; | ||
use Illuminate\Contracts\Config\Repository as ConfigRepository; | ||
use Illuminate\Contracts\Foundation\Application; | ||
use Illuminate\Contracts\Routing\UrlGenerator; | ||
use Illuminate\Contracts\Translation\Translator; | ||
use Illuminate\Http\Request; | ||
use Illuminate\Routing\Router; | ||
|
||
class MyLaravelLocalization extends LaravelLocalization | ||
{ | ||
public function __construct( | ||
mixed $myCustomVariable, | ||
Application $app, | ||
ConfigRepository $configRepository, | ||
Translator $translator, | ||
Router $router, | ||
Request $request, | ||
UrlGenerator $url | ||
) { | ||
parent::__construct($app, $configRepository, $translator, $router, $request, $url); | ||
} | ||
} | ||
``` | ||
|
||
If your previous approach involved overriding the `LaravelLocalization` singleton in the container and generating a new instance of your custom implementation, there's now a more straightforward method for binding. This will automatically inject the correct dependencies for you. | ||
```diff | ||
use Mcamara\LaravelLocalization\LaravelLocalization; | ||
|
||
-$this->app->singleton(LaravelLocalization::class, function () { | ||
- return new MyLaravelLocalization(); | ||
-}); | ||
+$this->app->singleton(LaravelLocalization::class, MyLaravelLocalization::class); | ||
``` | ||
|
||
For more information, please see the following PR [#879](https://github.com/mcamara/laravel-localization/pull/879/files) |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.