Issues (74)

src/Context/ProdModule.php (1 issue)

Labels
Severity
1
<?php
2
3
declare(strict_types=1);
4
5
namespace BEAR\Package\Context;
6
7
use BEAR\Package\Provide\Cache\CacheDirProvider;
8
use BEAR\Package\Provide\Error\ErrorPageFactoryInterface;
9
use BEAR\Package\Provide\Error\ProdVndErrorPageFactory;
10
use BEAR\Package\Provide\Logger\ProdMonologProvider;
11
use BEAR\QueryRepository\ProdQueryRepositoryModule;
12
use BEAR\RepositoryModule\Annotation\EtagPool;
13
use BEAR\Resource\NullOptionsRenderer;
14
use BEAR\Resource\RenderInterface;
15
use Override;
16
use Psr\Cache\CacheItemInterface;
17
use Psr\Log\LoggerInterface;
18
use Ray\Compiler\DiCompileModule;
19
use Ray\Di\AbstractModule;
20
use Ray\Di\Scope;
21
use Ray\PsrCacheModule\Annotation\CacheDir;
22
use Ray\PsrCacheModule\LocalCacheProvider;
0 ignored issues
show
The type Ray\PsrCacheModule\LocalCacheProvider was not found. Maybe you did not declare it correctly or list all dependencies?

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:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
23
use Ray\PsrCacheModule\Psr6LocalCacheModule;
24
25
/** @codeCoverageIgnore */
26
final class ProdModule extends AbstractModule
27
{
28
    /**
29
     * {@inheritDoc}
30
     */
31
    #[Override]
32
    protected function configure(): void
33
    {
34
        $this->bind(ErrorPageFactoryInterface::class)->to(ProdVndErrorPageFactory::class);
35
        $this->bind(LoggerInterface::class)->toProvider(ProdMonologProvider::class)->in(Scope::SINGLETON);
36
        $this->disableOptionsMethod();
37
        $this->installCacheModule();
38
        $this->install(new DiCompileModule(true));
39
    }
40
41
    private function installCacheModule(): void
42
    {
43
        $this->install(new ProdQueryRepositoryModule());
44
        /** @deprecated This binding is no longer used by Ray.PsrCacheModule */
45
        /** @psalm-suppress DeprecatedClass */
46
        $this->bind('')->annotatedWith(CacheDir::class)->toProvider(CacheDirProvider::class);
47
        $this->install(new Psr6LocalCacheModule());
48
        /** @psalm-suppress DeprecatedClass */
49
        $this->bind(CacheItemInterface::class)->annotatedWith(EtagPool::class)->toProvider(LocalCacheProvider::class);
50
    }
51
52
    /**
53
     * Disable OPTIONS resource request method in production
54
     *
55
     * OPTIONS method return 405 Method Not Allowed error code. To enable OPTIONS in `prod` context,
56
     * Install BEAR\Resource\Module\OptionsMethodModule() in your ProdModule.
57
     */
58
    private function disableOptionsMethod(): void
59
    {
60
        $this->bind(RenderInterface::class)->annotatedWith('options')->to(NullOptionsRenderer::class);
61
    }
62
}
63