GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

Component   A
last analyzed

Complexity

Total Complexity 16

Size/Duplication

Total Lines 161
Duplicated Lines 0 %

Test Coverage

Coverage 5%

Importance

Changes 6
Bugs 0 Features 0
Metric Value
eloc 80
c 6
b 0
f 0
dl 0
loc 161
ccs 2
cts 40
cp 0.05
rs 10
wmc 16

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getDependedComponentClasses() 0 26 1
A boot() 0 20 3
A initComponentConfiguration() 0 15 1
A getContainerCompilerPassClasses() 0 4 1
B initializeContainerServices() 0 63 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace GraphQLAPI\GraphQLAPI;
6
7
use GraphQLAPI\GraphQLAPI\Config\ServiceConfiguration;
8
use GraphQLAPI\GraphQLAPI\Container\CompilerPasses\RegisterAccessControlRuleBlockCompilerPass;
9
use GraphQLAPI\GraphQLAPI\Facades\ModuleRegistryFacade;
10
use GraphQLAPI\GraphQLAPI\Facades\UserSettingsManagerFacade;
11
use GraphQLAPI\GraphQLAPI\ModuleResolvers\CacheFunctionalityModuleResolver;
12
use GraphQLAPI\GraphQLAPI\ModuleResolvers\ClientFunctionalityModuleResolver;
13
use GraphQLAPI\GraphQLAPI\ModuleResolvers\PerformanceFunctionalityModuleResolver;
14
use GraphQLAPI\GraphQLAPI\SchemaConfiguratorExecuters\EditingPersistedQuerySchemaConfiguratorExecuter;
15
use GraphQLAPI\GraphQLAPI\SchemaConfiguratorExecuters\EndpointSchemaConfiguratorExecuter;
16
use GraphQLAPI\GraphQLAPI\SchemaConfiguratorExecuters\PersistedQuerySchemaConfiguratorExecuter;
17
use PoP\CacheControl\DirectiveResolvers\CacheControlDirectiveResolver;
18
use PoP\ComponentModel\ComponentConfiguration as ComponentModelComponentConfiguration;
19
use PoP\ComponentModel\ComponentConfiguration\ComponentConfigurationHelpers;
20
use PoP\ComponentModel\Environment as ComponentModelEnvironment;
21
use PoP\ComponentModel\Facades\Engine\DataloadingEngineFacade;
22
use PoP\Root\Component\AbstractComponent;
23
24
/**
25
 * Initialize component
26
 */
27
class Component extends AbstractComponent
28
{
29
    /**
30
     * Classes from PoP components that must be initialized before this component
31
     *
32
     * @return string[]
33
     */
34
    public static function getDependedComponentClasses(): array
35
    {
36
        return [
37 1
            \PoPSchema\GenericCustomPosts\Component::class,
38
            \PoPSchema\CommentMetaWP\Component::class,
39
            \GraphQLByPoP\GraphQLServer\Component::class,
40 1
            \PoPSchema\MediaWP\Component::class,
41
            \PoPSchema\PostsWP\Component::class,
42
            \PoPSchema\PagesWP\Component::class,
43
            \PoPSchema\CustomPostMediaWP\Component::class,
44
            \PoPSchema\CustomPostMetaWP\Component::class,
45
            \PoPSchema\TaxonomyQueryWP\Component::class,
46
            \PoPSchema\PostTagsWP\Component::class,
47
            \PoPSchema\UserRolesAccessControl\Component::class,
48
            \PoPSchema\UserRolesWP\Component::class,
49
            \PoPSchema\UserStateWP\Component::class,
50
            \PoPSchema\UserMetaWP\Component::class,
51
            \PoPSchema\CustomPostMutationsWP\Component::class,
52
            \PoPSchema\PostMutations\Component::class,
53
            \PoPSchema\CustomPostMediaMutationsWP\Component::class,
54
            \PoPSchema\CommentMutationsWP\Component::class,
55
            \PoPSchema\UserStateMutationsWP\Component::class,
56
            \PoPSchema\BasicDirectives\Component::class,
57
            \GraphQLByPoP\GraphQLClientsForWP\Component::class,
58
            \GraphQLByPoP\GraphQLEndpointForWP\Component::class,
59
            \GraphQLAPI\MarkdownConvertor\Component::class,
60
        ];
61
    }
62
63
    /**
64
     * Initialize services
65
     *
66
     * @param array<string, mixed> $configuration
67
     * @param string[] $skipSchemaComponentClasses
68
     */
69
    protected static function initializeContainerServices(
70
        array $configuration = [],
71
        bool $skipSchema = false,
72
        array $skipSchemaComponentClasses = []
73
    ): void {
74
        parent::initializeContainerServices($configuration, $skipSchema, $skipSchemaComponentClasses);
0 ignored issues
show
Bug introduced by
The method initializeContainerServices() does not exist on PoP\Root\Component\AbstractComponent. Did you maybe mean initialize()? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

74
        parent::/** @scrutinizer ignore-call */ 
75
                initializeContainerServices($configuration, $skipSchema, $skipSchemaComponentClasses);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
75
        self::initYAMLServices(dirname(__DIR__));
76
        self::initComponentConfiguration();
77
        // Override DI services
78
        self::initYAMLServices(dirname(__DIR__), '/Overrides');
79
        // Conditional DI settings
80
        /**
81
         * FieldResolvers used to configure the services can also be accessed in the admin area
82
         */
83
        if (\is_admin()) {
84
            self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/Admin');
85
            self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/Admin', 'schema-services.yaml');
86
        }
87
        // Register the Cache services, if the module is not disabled
88
        $moduleRegistry = ModuleRegistryFacade::getInstance();
89
        if ($moduleRegistry->isModuleEnabled(CacheFunctionalityModuleResolver::CONFIGURATION_CACHE)) {
90
            self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/ConfigurationCache/Overrides');
91
        }
92
        // Maybe use GraphiQL with Explorer
93
        $userSettingsManager = UserSettingsManagerFacade::getInstance();
94
        $isGraphiQLExplorerEnabled = $moduleRegistry->isModuleEnabled(ClientFunctionalityModuleResolver::GRAPHIQL_EXPLORER);
95
        if (
96
            \is_admin()
97
            && $isGraphiQLExplorerEnabled
98
            && $userSettingsManager->getSetting(
99
                ClientFunctionalityModuleResolver::GRAPHIQL_EXPLORER,
100
                ClientFunctionalityModuleResolver::OPTION_USE_IN_ADMIN_CLIENT
101
            )
102
        ) {
103
            self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/Admin/ConditionalOnEnvironment/GraphiQLExplorerInAdminClient/Overrides');
104
        }
105
        if ($isGraphiQLExplorerEnabled) {
106
            if (
107
                $userSettingsManager->getSetting(
108
                    ClientFunctionalityModuleResolver::GRAPHIQL_EXPLORER,
109
                    ClientFunctionalityModuleResolver::OPTION_USE_IN_ADMIN_PERSISTED_QUERIES
110
                )
111
            ) {
112
                self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/GraphiQLExplorerInAdminPersistedQueries/Overrides');
113
            }
114
            if (
115
                $userSettingsManager->getSetting(
116
                    ClientFunctionalityModuleResolver::GRAPHIQL_EXPLORER,
117
                    ClientFunctionalityModuleResolver::OPTION_USE_IN_PUBLIC_CLIENT_FOR_SINGLE_ENDPOINT
118
                )
119
            ) {
120
                self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/GraphiQLExplorerInSingleEndpointPublicClient/Overrides');
121
            }
122
            if (
123
                $userSettingsManager->getSetting(
124
                    ClientFunctionalityModuleResolver::GRAPHIQL_EXPLORER,
125
                    ClientFunctionalityModuleResolver::OPTION_USE_IN_PUBLIC_CLIENT_FOR_CUSTOM_ENDPOINTS
126
                )
127
            ) {
128
                self::initYAMLServices(dirname(__DIR__), '/ConditionalOnEnvironment/GraphiQLExplorerInCustomEndpointPublicClient/Overrides');
129
            }
130
        }
131
        ServiceConfiguration::initialize();
132
    }
133
134
    protected static function initComponentConfiguration(): void
135
    {
136
        /**
137
         * Enable the schema entity registries, as to retrieve the type/directive resolver classes
138
         * from the type/directive names, saved in the DB in the ACL/CCL Custom Post Types
139
         */
140
        $hookName = ComponentConfigurationHelpers::getHookName(
141
            ComponentModelComponentConfiguration::class,
142
            ComponentModelEnvironment::ENABLE_SCHEMA_ENTITY_REGISTRIES
143
        );
144
        \add_filter(
145
            $hookName,
146
            fn () => true,
147
            PHP_INT_MAX,
148
            1
149
        );
150
    }
151
152
    /**
153
     * Boot component
154
     *
155
     * @return void
156
     */
157
    public static function boot(): void
158
    {
159
        parent::boot();
160
161
        // Enable the CacheControl, if the module is not disabled
162
        $moduleRegistry = ModuleRegistryFacade::getInstance();
163
        if ($moduleRegistry->isModuleEnabled(PerformanceFunctionalityModuleResolver::CACHE_CONTROL)) {
164
            // Unless previewing the query
165
            if (!\is_preview()) {
166
                $dataloadingEngine = DataloadingEngineFacade::getInstance();
167
                $dataloadingEngine->addMandatoryDirectives([
168
                    CacheControlDirectiveResolver::getDirectiveName(),
169
                ]);
170
            }
171
        }
172
173
        // Configure the GraphQL query with Access/Cache Control Lists
174
        (new PersistedQuerySchemaConfiguratorExecuter())->init();
175
        (new EndpointSchemaConfiguratorExecuter())->init();
176
        (new EditingPersistedQuerySchemaConfiguratorExecuter())->init();
177
    }
178
179
    /**
180
     * Get all the compiler pass classes required to register on the container
181
     *
182
     * @return string[]
183
     */
184
    public static function getContainerCompilerPassClasses(): array
185
    {
186
        return [
187
            RegisterAccessControlRuleBlockCompilerPass::class,
188
        ];
189
    }
190
}
191