checkConfiguration example

'name' => $plugin->getName(),
            'label' => $plugin->getTranslation('label'),
            'producerName' => $plugin->getAuthor(),
            'license' => $plugin->getLicense(),
            'version' => $plugin->getVersion(),
            'latestVersion' => $plugin->getUpgradeVersion(),
            'iconRaw' => $plugin->getIcon(),
            'installedAt' => $plugin->getInstalledAt(),
            'active' => $plugin->getActive(),
            'type' => ExtensionStruct::EXTENSION_TYPE_PLUGIN,
            'isTheme' => $isTheme,
            'configurable' => $this->configurationService->checkConfiguration(sprintf('%s.config', $plugin->getName())$context),
            'updatedAt' => $plugin->getUpgradedAt(),
            'allowDisable' => true,
        ];

        return ExtensionStruct::fromArray($this->replaceCollections($data));
    }

    /** * @return array<string> */
    private function getInstalledThemeNames(Context $context): array
    {


    #[Route(path: '/api/_action/system-config/check', name: 'api.action.core.system-config.check', defaults: ['_acl' => ['system_config:read']], methods: ['GET'])]     public function checkConfiguration(Request $request, Context $context): JsonResponse
    {
        $domain = (string) $request->query->get('domain');

        if ($domain === '') {
            return new JsonResponse(false);
        }

        return new JsonResponse($this->configurationService->checkConfiguration($domain$context));
    }

    #[Route(path: '/api/_action/system-config/schema', name: 'api.action.core.system-config', methods: ['GET'])]     public function getConfiguration(Request $request, Context $context): JsonResponse
    {
        $domain = (string) $request->query->get('domain');

        if ($domain === '') {
            throw RoutingException::missingRequestParameter('domain');
        }

        

        $controller = new SystemConfigController(
            $this->createMock(ConfigurationService::class),
            $this->createMock(SystemConfigService::class),
            $this->createMock(SystemConfigValidator::class)
        );

        $request = new Request();

        $context = Context::createDefaultContext();

        $result = $controller->checkConfiguration($request$context);

        static::assertSame('false', $result->getContent());
    }

    public function testCheckConfiguration(): void
    {
        $configurationService = $this->createMock(ConfigurationService::class);
        $configurationService
            ->method('checkConfiguration')
            ->willReturn(true);

        
$this->expectException(\InvalidArgumentException::class);
        $this->expectExceptionMessage('Expected domain');

        $configService = new ConfigurationService(
            [],
            new ConfigReader(),
            $this->createMock(AppLoader::class),
            new StaticEntityRepository([]),
            new StaticSystemConfigService([])
        );

        static::assertFalse($configService->checkConfiguration('invalid!', Context::createDefaultContext()));

        $configService->getConfiguration('invalid!', Context::createDefaultContext());
    }

    public function testMissingConfig(): void
    {
        $this->expectException(ConfigurationNotFoundException::class);

        $configService = new ConfigurationService(
            [],
            new ConfigReader(),
            


        return $config;
    }

    /** * @return array<mixed> */
    public function getResolvedConfiguration(string $domain, Context $context, ?string $salesChannelId = null): array
    {
        $config = [];
        if ($this->checkConfiguration($domain$context)) {
            $config = array_merge(
                $config,
                $this->enrichValues(
                    $this->getConfiguration($domain$context),
                    $salesChannelId
                )
            );
        }

        return $config;
    }

    
Home | Imprint | This part of the site doesn't use cookies.