mirror of
https://github.com/DirectoryLister/DirectoryLister.git
synced 2025-08-22 21:54:15 +02:00
Converted Collections in container definition back to arrays
This commit is contained in:
@@ -6,7 +6,6 @@ use App\SortMethods;
|
||||
use App\ViewFunctions;
|
||||
use Middlewares as HttpMiddlewares;
|
||||
use Psr\Container\ContainerInterface;
|
||||
use Tightenco\Collect\Support\Collection;
|
||||
|
||||
return [
|
||||
/** Path definitions */
|
||||
@@ -22,33 +21,29 @@ return [
|
||||
/** Array of application files (to be hidden) */
|
||||
'app_files' => ['app', 'index.php', '.hidden'],
|
||||
|
||||
/** Collection of application middlewares */
|
||||
'middlewares' => function (ContainerInterface $container): Collection {
|
||||
return Collection::make([
|
||||
/** Array of application middlewares */
|
||||
'middlewares' => function (ContainerInterface $container): array {
|
||||
return [
|
||||
Middlewares\WhoopsMiddleware::class,
|
||||
new HttpMiddlewares\Expires($container->get('http_expires')),
|
||||
]);
|
||||
];
|
||||
},
|
||||
|
||||
/** Collection of sort options mapped to their respective classes */
|
||||
'sort_methods' => function (): Collection {
|
||||
return Collection::make([
|
||||
'accessed' => SortMethods\Accessed::class,
|
||||
'changed' => SortMethods\Changed::class,
|
||||
'modified' => SortMethods\Modified::class,
|
||||
'name' => SortMethods\Name::class,
|
||||
'natural' => SortMethods\Natural::class,
|
||||
'type' => SortMethods\Type::class,
|
||||
]);
|
||||
},
|
||||
/** Array of sort options mapped to their respective classes */
|
||||
'sort_methods' => [
|
||||
'accessed' => SortMethods\Accessed::class,
|
||||
'changed' => SortMethods\Changed::class,
|
||||
'modified' => SortMethods\Modified::class,
|
||||
'name' => SortMethods\Name::class,
|
||||
'natural' => SortMethods\Natural::class,
|
||||
'type' => SortMethods\Type::class,
|
||||
],
|
||||
|
||||
/** Collection of available translation languages */
|
||||
'translations' => function (): Collection {
|
||||
return Collection::make([
|
||||
'de', 'en', 'es', 'fr', 'id', 'it', 'kr', 'nl',
|
||||
'pl', 'pt-BR', 'ro', 'ru', 'zh-CN', 'zh-TW'
|
||||
]);
|
||||
},
|
||||
/** Array of available translation languages */
|
||||
'translations' => [
|
||||
'de', 'en', 'es', 'fr', 'id', 'it', 'kr', 'nl',
|
||||
'pl', 'pt-BR', 'ro', 'ru', 'zh-CN', 'zh-TW'
|
||||
],
|
||||
|
||||
/** Array of view functions */
|
||||
'view_functions' => [
|
||||
|
@@ -32,10 +32,8 @@ class MiddlewareManager
|
||||
*/
|
||||
public function __invoke(): void
|
||||
{
|
||||
$this->container->get('middlewares')->each(
|
||||
function ($middleware): void {
|
||||
$this->app->add($middleware);
|
||||
}
|
||||
);
|
||||
foreach ($this->container->get('middlewares') as $middleware) {
|
||||
$this->app->add($middleware);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -45,11 +45,11 @@ class FinderFactory
|
||||
if ($sortOrder instanceof Closure) {
|
||||
$finder->sort($sortOrder);
|
||||
} else {
|
||||
if (! $this->container->get('sort_methods')->has($sortOrder)) {
|
||||
if (! array_key_exists($sortOrder, $this->container->get('sort_methods'))) {
|
||||
throw new RuntimeException("Invalid sort option '{$sortOrder}'");
|
||||
}
|
||||
|
||||
$this->container->call($this->container->get('sort_methods')->get($sortOrder), [$finder]);
|
||||
$this->container->call($this->container->get('sort_methods')[$sortOrder], [$finder]);
|
||||
}
|
||||
|
||||
if ($this->container->get('reverse_sort')) {
|
||||
|
@@ -32,19 +32,18 @@ class TranslationFactory
|
||||
{
|
||||
$language = $this->container->get('language');
|
||||
|
||||
if (! $this->container->get('translations')->contains($language)) {
|
||||
if (! in_array($language, $this->container->get('translations'))) {
|
||||
throw new RuntimeException("Invalid language option '{$language}'");
|
||||
}
|
||||
|
||||
$translator = new Translator($language);
|
||||
$translator->addLoader('yaml', new YamlFileLoader());
|
||||
|
||||
$this->container->get('translations')->each(
|
||||
function (string $language) use ($translator): void {
|
||||
$resource = sprintf($this->container->get('translations_path') . '/%s.yaml', $language);
|
||||
$translator->addResource('yaml', $resource, $language);
|
||||
}
|
||||
);
|
||||
foreach ($this->container->get('translations') as $language) {
|
||||
$translator->addResource('yaml', sprintf(
|
||||
'%s/%s.yaml', $this->container->get('translations_path'), $language
|
||||
), $language);
|
||||
}
|
||||
|
||||
return $translator;
|
||||
}
|
||||
|
Reference in New Issue
Block a user