fetchAppPrivileges example


    public function get(string $key, ?string $salesChannelId = null)
    {
        if (!$salesChannelId) {
            $salesChannelId = $this->salesChannelId;
        }

        if ($this->scriptAppInformation) {
            $privileges = $this->fetchAppPrivileges($this->scriptAppInformation->getAppId());

            if (!\in_array(self::PRIVILEGE, $privileges, true)) {
                throw new MissingPrivilegeException([self::PRIVILEGE]);
            }
        }

        return $this->systemConfigService->get($key$salesChannelId);
    }

    /** * The `app()` method allows you to access the config values your app's configuration. * Notice that your app does not need any additional privileges to use this method, as you can only access your own app's configuration. * * @param string $key The name of the configuration value specified in the config.xml e.g. `exampleTextField`. * @param string|null $salesChannelId The SalesChannelId if you need the config value for a specific SalesChannel, if you don't provide a SalesChannelId, the one of the current Context is used as default. * * @return array|bool|float|int|string|null * * @example test-config/script.twig 5 1 Read your app's config value. */
Home | Imprint | This part of the site doesn't use cookies.