|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
declare(strict_types=1); |
|
4
|
|
|
|
|
5
|
|
|
namespace Hyde\Foundation\Concerns; |
|
6
|
|
|
|
|
7
|
|
|
use Hyde\Facades\Config; |
|
8
|
|
|
use Illuminate\Support\Collection; |
|
9
|
|
|
use Hyde\Framework\Features\Blogging\Models\PostAuthor; |
|
|
|
|
|
|
10
|
|
|
use Hyde\Framework\Exceptions\InvalidConfigurationException; |
|
11
|
|
|
|
|
12
|
|
|
use function collect; |
|
13
|
|
|
|
|
14
|
|
|
/** |
|
15
|
|
|
* Contains accessors and containers for general data stored in the kernel. |
|
16
|
|
|
* |
|
17
|
|
|
* @internal Single-use trait for the HydeKernel class. |
|
18
|
|
|
* |
|
19
|
|
|
* @see \Hyde\Foundation\HydeKernel |
|
20
|
|
|
*/ |
|
21
|
|
|
trait HasKernelData |
|
22
|
|
|
{ |
|
23
|
|
|
/** |
|
24
|
|
|
* The collection of authors defined in the config. |
|
25
|
|
|
* |
|
26
|
|
|
* @var \Illuminate\Support\Collection<string, \Hyde\Framework\Features\Blogging\Models\PostAuthor> |
|
27
|
|
|
*/ |
|
28
|
|
|
protected Collection $authors; |
|
29
|
|
|
|
|
30
|
|
|
/** |
|
31
|
|
|
* Get the collection of authors defined in the config. |
|
32
|
|
|
* |
|
33
|
|
|
* @return \Illuminate\Support\Collection<string, \Hyde\Framework\Features\Blogging\Models\PostAuthor> |
|
34
|
|
|
*/ |
|
35
|
|
|
public function authors(): Collection |
|
36
|
|
|
{ |
|
37
|
|
|
if (isset($this->authors)) { |
|
38
|
|
|
return $this->authors; |
|
39
|
|
|
} |
|
40
|
|
|
|
|
41
|
|
|
$config = collect(Config::getArray('hyde.authors', [])); |
|
|
|
|
|
|
42
|
|
|
|
|
43
|
|
|
if ($config->isEmpty()) { |
|
44
|
|
|
// Defer setting the authors property until the next try. |
|
45
|
|
|
return $config; |
|
46
|
|
|
} |
|
47
|
|
|
|
|
48
|
|
|
return $this->authors = $this->parseConfigurationAuthors($config); |
|
49
|
|
|
} |
|
50
|
|
|
|
|
51
|
|
|
protected function parseConfigurationAuthors(Collection $authors): Collection |
|
52
|
|
|
{ |
|
53
|
|
|
return $authors->mapWithKeys(function (array $author, string $username): array { |
|
54
|
|
|
if (! $username) { |
|
55
|
|
|
throw new InvalidConfigurationException('Author username cannot be empty. Did you forget to set the author\'s array key?', 'hyde', 'authors'); |
|
56
|
|
|
} |
|
57
|
|
|
|
|
58
|
|
|
$username = PostAuthor::normalizeUsername($username); |
|
59
|
|
|
|
|
60
|
|
|
$author['username'] = $username; |
|
61
|
|
|
|
|
62
|
|
|
return [$username => PostAuthor::create($author)]; |
|
63
|
|
|
}); |
|
64
|
|
|
} |
|
65
|
|
|
} |
|
66
|
|
|
|
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