Skip to content
This repository has been archived by the owner on Feb 17, 2022. It is now read-only.

Commit

Permalink
Added callable condition call fallback.
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkGhostHunter committed Apr 7, 2021
1 parent a21cdd7 commit 3a97259
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 8 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,15 @@ jobs:
fail-fast: true
matrix:
php: [8.0, 7.4]
laravel: [8.*, 7.*]
laravel: [8.*, 7.*, 6.*]
dependency-version: [prefer-stable, prefer-lowest]
include:
- laravel: 8.*
testbench: 6.*
- laravel: 7.*
testbench: 5.*
- laravel: 6.*
testbench: ^4.1

name: PHP ${{ matrix.php }} - Laravel ${{ matrix.laravel }} - ${{ matrix.dependency-version }}

Expand Down
12 changes: 6 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,17 @@
],
"require": {
"php": "^7.4.3||^8.0.2",
"illuminate/support": "^7.0||^8.0",
"illuminate/http": "^7.0||^8.0",
"illuminate/events": "^7.0||^8.0",
"illuminate/support": "^6.0||^7.0||^8.0",
"illuminate/http": "^6.0||^7.0||^8.0",
"illuminate/events": "^6.0||^7.0||^8.0",
"darkghosthunter/preloader": "^2.2.0",
"symfony/finder": "^5.0"
"symfony/finder": "^4.3||^5.0"
},
"require-dev": {
"orchestra/testbench": "^5.0||^6.0",
"orchestra/testbench": "^4.1||^5.0||^6.0",
"phpunit/phpunit": "^9.3",
"mockery/mockery": "^1.4",
"orchestra/canvas": "^5.0||^6.0"
"orchestra/canvas": "^4.0||^5.0||^6.0"
},
"autoload": {
"psr-4": {
Expand Down
7 changes: 6 additions & 1 deletion src/Http/Middleware/LaraloadMiddleware.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,11 @@ protected function responseNotError($response): bool
*/
protected function conditionIsTrue(): bool
{
return (bool)$this->container->call($this->config->get('laraload.condition'));
$callable = $this->config->get('laraload.condition');

// If the callable is a class name, we will use call with invocation.
return class_exists($callable) && is_callable($callable)
? $this->container->call($callable, [], '__invoke')
: $this->container->call($callable);
}
}

0 comments on commit 3a97259

Please sign in to comment.