1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Translation\Routes; |
4
|
|
|
|
5
|
|
|
use Illuminate\Routing\ResourceRegistrar as LRR; |
|
|
|
|
6
|
|
|
use Illuminate\Routing\Router; |
|
|
|
|
7
|
|
|
use Translation\Repositories\LanguageRepository; |
8
|
|
|
|
9
|
|
|
class ResourceRegistrar extends LRR |
10
|
|
|
{ |
11
|
|
|
/** |
12
|
|
|
* The language repository. |
13
|
|
|
* |
14
|
|
|
* @var array |
15
|
|
|
*/ |
16
|
|
|
protected $languageRepository; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* Create a new resource registrar instance. |
20
|
|
|
* |
21
|
|
|
* @param \Illuminate\Routing\Router $router |
22
|
|
|
* @return void |
23
|
|
|
*/ |
24
|
|
|
public function __construct(Router $router, LanguageRepository $languageRepository) |
25
|
|
|
{ |
26
|
|
|
parent::__construct($router); |
27
|
|
|
$this->languageRepository = $languageRepository; |
|
|
|
|
28
|
|
|
} |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Get the resource name for a grouped resource. |
32
|
|
|
* |
33
|
|
|
* @param string $prefix |
34
|
|
|
* @param string $resource |
35
|
|
|
* @param string $method |
36
|
|
|
* @return string |
37
|
|
|
*/ |
38
|
|
|
protected function getGroupResourceName($prefix, $resource, $method) |
39
|
|
|
{ |
40
|
|
|
$availableLocales = $this->languageRepository->availableLocales(); |
41
|
|
|
|
42
|
|
|
// Remove segments from group prefix that are equal to one of the available locales: |
43
|
|
|
$groupSegments = explode('/', $this->router->getLastGroupPrefix()); |
44
|
|
|
$groupSegments = array_filter( |
45
|
|
|
$groupSegments, function ($segment) use ($availableLocales) { |
46
|
|
|
return !in_array($segment, $availableLocales); |
47
|
|
|
} |
48
|
|
|
); |
49
|
|
|
$group = trim(implode('.', $groupSegments), '.'); |
50
|
|
|
|
51
|
|
|
if (empty($group)) { |
52
|
|
|
return trim("{$prefix}{$resource}.{$method}", '.'); |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
return trim("{$prefix}{$group}.{$resource}.{$method}", '.'); |
56
|
|
|
} |
57
|
|
|
} |
58
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths