Write additional configuration array to typo3conf/AdditionalConfiguration.php

@param array $additionalConfigurationLines The configuration lines to be written
@throws \RuntimeException
@return bool TRUE on success
@internal
501787
public function writeAdditionalConfiguration(array $additionalConfigurationLines)
    {
        return GeneralUtility::writeFile(
            Environment::getPublicPath() . '/' . $this->additionalConfigurationFile,
            '<?php' . LF .
                implode(LF, $additionalConfigurationLines) . LF
        );
    }
677913
private function isValidConfigs(array $configs): void
    {
        $allowedConfigKeys = $this->getAllowedConfigKeys();
        if (!empty($configs)) {
            foreach ($configs as $key => $value) {
                if (!\in_array($key, $allowedConfigKeys, true)) {
                    throw new InvalidKeyException(sprintf(
                        '%s is not a valid key. configs must only contain "%s".',
                        $key,
                        implode(', ', $allowedConfigKeys)
                    ));
                }

                $this->isBool($key, $value);
                $this->isString($key, $value);
                $this->isValidNBest($key, $value);
            }
        }
    }
766028
protected function loadAdditionalConfigFiles() {
        $additionalConfigFiles = [];

        foreach ($this->config['options'] as $option => $value) {
            if (in_array($option, ['c', 'config'])) {
                switch (gettype($value)) {
                    case 'string':
                        $additionalConfigFiles[] = $value;
                        break;
                    case 'array':
                        foreach ($value as $item) {
                            if (!is_string($item)) {
                                throw new Exception(sprintf(
                                    'Unknown value "%s" for option "%s"',
                                    $item,
                                    $option
                                ), ExitApp::BAD_USER_INTERACTION);
                            }

                            $additionalConfigFiles[] = $item;
                        }
                        break;
                    default:
                        throw new Exception(sprintf(
                            'Unknown value "%s" for option "%s"',
                            $value,
                            $option
                        ), ExitApp::BAD_USER_INTERACTION);
                }
            }
        }

        foreach ($additionalConfigFiles as $additionalConfigFile) {
            $this->addConfigFile($additionalConfigFile);
        }

        return $this;
    }
759086
private static function mergeConfig(array $extra)
    {
        return array_merge([
            'include'              => [],
            'require'              => [],
            'recurse'              => true,
            'replace'              => false,
            'ignore-duplicates'    => false,
            'prepend-repositories' => false,
            'merge-dev'            => true,
            'merge-extra'          => false,
            'merge-extra-deep'     => false,
            'merge-scripts'        => false,
        ], $extra['merge-plugin'] ?? []);
    }
993763
public function additionalArgs(array $args) : void
    {
        foreach ($args as $a) {
            //match --extends
            if (substr($a, 0, strlen("--extends=")) == "--extends=") {
                $this->extends = explode("=", $a);
                $this->extends = $this->extends[1];
                continue;
            }

            if ($a == "--no-factory") {
                $this->createFactory = false;
                continue;
            }

            if (substr($a, 0, strlen("--test=")) == "--test=") {
                $this->test = explode("=", $a)[1];
                continue;
            }
        }
    }
1332862
public function specifyAdditionalParameters(array $data, array $additionalParams): array
    {
        foreach ($additionalParams as $param) {
            $method = 'get' . ucfirst($param);
            if (method_exists($this, $method)) {
                $value = $this->{$method}();
                if ($value) {
                    $data[$param] = $value;
                }
            }
        }
        return $data;
    }
44677
private function readBundleConfiguration(): array
    {
        $configurationFilePath = $this->getApplicationDir() . '/config/bundles.yml';
        if (!is_readable($configurationFilePath)) {
            throw new \RuntimeException('The file "' . $configurationFilePath . '" could not be read.', 1504272377);
        }

        return Yaml::parse(file_get_contents($configurationFilePath));
    }
1042847
public function updateAction(array $siteConfigurations)
    {
        foreach ($siteConfigurations as $siteConfiguration) {
            if ($this->persistenceManager->isNewObject($siteConfiguration)) {
                $this->siteConfigurationRepository->add($siteConfiguration);
            } else {
                $this->siteConfigurationRepository->update($siteConfiguration);
            }
        }

        $this->emitSiteConfigurationChanged();

        $this->addFlashMessage('Configuration has been updated.', 'Update', null, [], 1417109043);
        $this->redirect('index');
    }
641772
private function validateRoutesSectionInExtra(array $extra)
    {
        if (!isset($extra['phplist/core'])) {
            return;
        }
        $this->validatePhpListSectionInExtra($extra);

        if (!isset($extra['phplist/core']['routes'])) {
            return;
        }
        if (!is_array($extra['phplist/core']['routes'])) {
            throw new \InvalidArgumentException(
                'The extras.phplist/core.routes section in the composer.json must be an array.',
                1506429004
            );
        }

        /** @var array $bundleExtras */
        $bundleExtras = $extra['phplist/core']['routes'];
        foreach ($bundleExtras as $routeName => $routeConfiguration) {
            if (!is_array($routeConfiguration)) {
                throw new \InvalidArgumentException(
                    'The extras.phplist/core.routes. ' . $routeName .
                    '" section in the composer.json must be an array.',
                    1506429860
                );
            }
        }
    }
200974
protected function configure()
    {
        $request = $this->getRequest();

        $adminCode = $request->get('_sonata_admin');

        if (!$adminCode) {
            throw new \RuntimeException(sprintf(
                'There is no `_sonata_admin` defined for the controller `%s` and the current route `%s`',
                \get_class($this),
                $request->get('_route')
            ));
        }

        $this->admin = $this->container->get('sonata.admin.pool')->getAdminByAdminCode($adminCode);

        if (!$this->admin) {
            throw new \RuntimeException(sprintf(
                'Unable to find the admin class related to the current controller (%s)',
                \get_class($this)
            ));
        }

        $this->templateRegistry = $this->container->get($this->admin->getCode().'.template_registry');
        if (!$this->templateRegistry instanceof TemplateRegistryInterface) {
            throw new \RuntimeException(sprintf(
                'Unable to find the template registry related to the current admin (%s)',
                $this->admin->getCode()
            ));
        }

        $rootAdmin = $this->admin;

        while ($rootAdmin->isChild()) {
            $rootAdmin->setCurrentChild(true);
            $rootAdmin = $rootAdmin->getParent();
        }

        $rootAdmin->setRequest($request);

        if ($request->get('uniqid')) {
            $this->admin->setUniqid($request->get('uniqid'));
        }
    }
179134
public function addAdditionalScript($additionalScript): void
    {
        if (!$additionalScript instanceof HtmlElementInterface) {
            $additionalScript = new HtmlString($additionalScript);
        }
        $this->webLibraries[] = new InlineWebLibrary(null, null, $additionalScript);
    }
518616
protected function mergeProperties(BundleSchemaInterface $bundleSchema, array $additionalBundleSchemaCollection): array
    {
        $bundleSchemaProperties = $this->schemaBuilder->buildProperties($bundleSchema->getSchema());

        $propertiesToMerge = [];
        foreach ($additionalBundleSchemaCollection as $additionalBundleSchema) {
            $additionalProperties = $this->schemaBuilder->buildProperties(
                $additionalBundleSchema->getSchema()
            );

            $this->schemaValidator->assertProperties(
                $bundleSchema,
                $bundleSchemaProperties,
                $additionalBundleSchema,
                $additionalProperties
            );

            $propertiesToMerge = \array_merge(
                $propertiesToMerge,
                $additionalProperties
            );
        }

        $bundleSchemaProperties = \array_merge($bundleSchemaProperties, $propertiesToMerge);

        return $bundleSchemaProperties;
    }
483647
public function addConfiguration($name, array $config)
    {
        if(array_key_exists($name, $this->configs)) {
            throw new \RuntimeException(
                "Connection with given name already exists!"
            );
        }

        $this->configs[$name] = $config;
    }
326863
public function getTemplateVars(array $extra = [])
    {
        $extraKeys = array_keys($extra);
        if (0 < count($extraKeys)) {
            foreach (array_keys($this->resources) as $key) {
                if (array_key_exists($key, $extraKeys)) {
                    throw new \RuntimeException(sprintf('Key "%s" used in extra template vars overrides a resource key.', $key));
                }
            }
            foreach (['identifiers', 'resource_name', 'resource_id', 'route_prefix'] as $key) {
                if (array_key_exists($key, $extraKeys)) {
                    throw new \RuntimeException(sprintf('Key "%s" is reserved and cannot be used in extra template vars.', $key));
                }
            }
        }

        return array_merge($this->resources, [
            'identifiers'   => $this->getIdentifiers(),
            'resource_name' => $this->config->getResourceName(),
            'resource_id'   => $this->config->getId(),
            'route_prefix'  => $this->config->getRoutePrefix(),
            'form_template' => $this->config->getTemplate('_form.html'),
        ], $extra);
    }
284112
public function register($additionalParameters = null)
    {
        if ($additionalParameters && !is_object($additionalParameters)) {
            throw new \Exception('additionalParameters must be an object');
        }

        //Ignore registration if disabled setting is set to true
        if (isset($this->settings->disabled) && $this->settings->disabled) {
            return false;
        }

        //Get current global adapter
        $internalAdapter = \Phramework\Database\Database::getAdapter();

        if (!$internalAdapter) {
            throw new \Exception('Global database adapter is not initialized');
        }

        //Create new QueryLogAdapter instance, using current global adapter
        $queryLogAdapter = new QueryLogAdapter(
            $this->settings,
            $internalAdapter,
            $additionalParameters
        );

        //Set newly created QueryLogAdapter instance as global adapter
        \Phramework\Database\Database::setAdapter($queryLogAdapter);

        return true;
    }
1293701
public function mapConfig(array $enabledCustomTags)
    {
        $config = [];
        foreach ($enabledCustomTags as $tagName) {
            if (!isset($this->customTagsConfiguration[$tagName])) {
                throw new RuntimeException(
                    "RichText Custom Tag configuration for {$tagName} not found."
                );
            }

            $customTagConfiguration = $this->customTagsConfiguration[$tagName];

            $config[$tagName] = [
                'label' => "ezrichtext.custom_tags.{$tagName}.label",
                'description' => "ezrichtext.custom_tags.{$tagName}.description",
                'isInline' => $customTagConfiguration['is_inline'],
            ];

            if (!empty($customTagConfiguration['icon'])) {
                $config[$tagName]['icon'] = $this->packages->getUrl(
                    $customTagConfiguration['icon']
                );
            }

            foreach ($customTagConfiguration['attributes'] as $attributeName => $properties) {
                $typeMapper = $this->getAttributeTypeMapper(
                    $tagName,
                    $attributeName,
                    $properties['type']
                );
                $config[$tagName]['attributes'][$attributeName] = $typeMapper->mapConfig(
                    $tagName,
                    $attributeName,
                    $properties
                );
            }
        }

        return $this->translateLabels($config);
    }
694283
private function injectExtraConfig(PackageInterface $package, array $extra)
    {
        $ref = new \ReflectionClass($package);
        $met = $ref->getProperty('extra');
        $met->setAccessible(true);
        $met->setValue($package, $extra);
    }