Validates the bundles section in the "extra" section of the composer.json of a module.

@param array $extra

@return void

@throws \InvalidArgumentException if $extra has an invalid bundles configuration
182753
private function validateBundlesSectionInExtra(array $extra)
    {
        if (!isset($extra['phplist/core'])) {
            return;
        }
        $this->validatePhpListSectionInExtra($extra);

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

        /** @var array $bundleExtras */
        $bundleExtras = $extra['phplist/core']['bundles'];
        foreach ($bundleExtras as $key => $bundleName) {
            if (!is_string($bundleName)) {
                throw new \InvalidArgumentException(
                    'The extras.phplist/core.bundles. ' . $key . '" section in the composer.json must be a string.',
                    1505412184
                );
            }
        }
    }
1315639
private function validateAndSetBotParamsExtra(array $params)
    {
        foreach (self::$valid_extra_bot_params as $extra_key) {
            if (!array_key_exists($extra_key, $params)) {
                continue;
            }

            $this->bot_params[$extra_key] = $params[$extra_key];
        }
    }
235582
public function addExtra($extra)
    {
        $functions = $extra->getFunctions();
        if ($functions && is_array($functions)) {
            foreach ($functions as $function) {
                $this->twig->addFunction($function);
            }
        }
        $filters = $extra->getFilters();
        if ($filters && is_array($filters)) {
            foreach ($filters as $filter) {
                $this->twig->addFilter($filter);
            }
        }
        $globals = $extra->getGlobals();
        if ($globals && is_array($globals)) {
            foreach ($globals as $key => $value) {
                $this->twig->addGlobal($key, $value);
            }
        }
    }
1365211
private function validateBundle($bundle)
    {
        Validators::validateBundleName($bundle);

        try {
            $bundle = $this->getContainer()->get('kernel')->getBundle($bundle);
        } catch (\Exception $e) {
            throw new \RuntimeException('Cannot patch "%s", bundle not found.', $bundle);
        }

        if (!$bundle instanceof AbstractResourceBundle) {
            throw new \RuntimeException('You need to implement AbstractResourceBundle for "%s"', $bundle->getName());
        }

        return $bundle;
    }
314773
public function initFields ($extra = array())
    {
        if (array_key_exists('tag', $extra)) {
            $this->tag = $extra['tag'];
        }
        $this->tag = Geo_Shortcuts_tagFactory($this->tag);
        
        $this->fields['tag_key'] = new Pluf_Form_Field_Varchar(
                array(
                        'required' => false,
                        'label' => __('tag key'),
                        'initial' => $this->tag->tag_key
                ));
        $this->fields['tag_value'] = new Pluf_Form_Field_Varchar(
                array(
                        'required' => false,
                        'label' => __('tag value'),
                        'initial' => $this->tag->tag_value
                ));
        
        $this->fields['description'] = new Pluf_Form_Field_Varchar(
                array(
                        'required' => false,
                        'label' => __('location description'),
                        'initial' => $this->tag->description
                ));
    }
282774
public function addToBundle($name, $deps)
    {
        if ($name == '') {
            throw new exception\InvalidArgumentException('The require.js bundle name must not be empty');
        }

        if (!is_array($deps) && !($deps instanceof \Traversable)) {
            $deps = [ $deps ];
        }

        if (!isset($this->bundles[$name])) {
            $this->bundles[$name] = [];
        }

        foreach ($deps as $item) {
            $item = (string)$item;

            if ($item != '') {
                $this->bundles[$name][] = $item;
            }
        }

        return $this;
    }
101464
private function validateIncludeRegex($config): void
    {
        if (! Validator::key('include', Validator::stringType())->validate($config)
            && ! Validator::key('include', Validator::nullType())->validate($config)
        ) {
            throw new InvalidConfigException('"include" parameter must be set as a string or a null value.');
        }
    }
1267238
public function export($item, array $extraAttributes = ['group'], bool $useTypeSettings = false): array
    {
        /** @var Field $item*/
        $attributeObj = [];
        $extraAttributes = array_merge($extraAttributes, $this->additionalAttributes(\get_class($item)));
        if (\count($item::supportedTranslationMethods()) > 1) {
            $extraAttributes = array_merge($extraAttributes, ['translationMethod', 'translationKeyFormat']);
        }
        foreach($extraAttributes as $attribute) {
            if ($attribute === 'group') {
                $attributeObj[$attribute] = $item->$attribute->name;
                $attributeObj[$attribute . 'Id'] = $item->$attribute->id;
            } else if ($attribute === 'required') {
                $attributeObj[$attribute] = (bool) $item->$attribute;
            } else {
                $attributeObj[$attribute] = $item->$attribute;
            }
        }
        if ($useTypeSettings) {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
                'typesettings' => $item->getSettings(),
            ]);
        } else {
            $fieldObj = array_merge($attributeObj, [
                'name' => $item->name,
                'handle' => $item->handle,
                'instructions' => $item->instructions,
                'type' => \get_class($item),
            ], $item->getSettings());
        }

        if (isset($fieldObj['translationMethod']) && $fieldObj['translationMethod'] === 'none') {
            unset($fieldObj['translationMethod']);
        }

        if ($item instanceof Matrix) {
            /**
             * @var Matrix $item
             */
            $blockTypesObj = [];
            foreach ($item->getBlockTypes() as $blockType) {
                $blockTypeObj = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'fields' => [],
                ];
                foreach ($blockType->getFields() as $blockField) {
                    $blockTypeObj['fields'][] = $this->export($blockField, [ 'required' ], true);
                }
                $blockTypesObj[] = $blockTypeObj;
            }
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = $blockTypesObj;
            } else {
                $fieldObj['blockTypes'] = $blockTypesObj;
            }
            unset($fieldObj['contentTable']);
        } else if ($item instanceof Neo) {
            $blockTypesObj = [];
            $blockTypeGroupsObj = [];
            /**
             * @var Neo $item
             */
            foreach ($item->getGroups() as $group) {
                /* @var NeoBlockTypeGroup $blockType */
                $blockTypeGroupsObj[] = [
                    'name' => $group->name,
                    'sortOrder' => (int) $group->sortOrder
                ];
            }
            $fieldObj['groups'] = $blockTypeGroupsObj;
            foreach ($item->getBlockTypes() as $blockType) {
                /* @var NeoBlockType $blockType */
                $blockTypesObj[] = [
                    'name' => $blockType->name,
                    'handle' => $blockType->handle,
                    'sortOrder' => (int) $blockType->sortOrder,
                    'maxBlocks' => (int) $blockType->maxBlocks,
                    'childBlocks' => Json::decodeIfJson((string) $blockType->childBlocks),
                    'maxChildBlocks' => (int) $blockType->maxBlocks,
                    'topLevel' => (bool) $blockType->topLevel,
                    'fieldLayout' => $this->exportFieldLayout($blockType->getFieldLayout()),
                    'requiredFields' => $this->exportRequiredFields($blockType->getFieldLayout()),
                ];
            }
            $fieldObj['blockTypes'] = $blockTypesObj;
        } else if ($item instanceof Date) {
            /**
             * @var Date $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['dateTime'] = 'show' . (
                    ((bool) $fieldObj['typesettings']['showDate'] === false) ? 'Time' : (
                        ((bool) $fieldObj['typesettings']['showTime'] === false) ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['typesettings']['showDate'], $fieldObj['typesettings']['showTime']);
            } else {
                $fieldObj['dateTime'] = 'show' . (
                    ((bool) $fieldObj['showDate']) === false ? 'Time' : (
                        ((bool) $fieldObj['showTime']) === false ? 'Date' : 'Both'
                    )
                );
                unset($fieldObj['showDate'], $fieldObj['showTime']);
            }
        } else if ($item instanceof SuperTableField) {
            /**
             * @var SuperTableField $item
             */
            if ($useTypeSettings) {
                $fieldObj['typesettings']['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['typesettings']['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            } else {
                $fieldObj['blockTypes'] = [];
                foreach ($item->getBlockTypeFields() as $blockTypeField) {
                    $fieldObj['blockTypes'][] = $this->export($blockTypeField, [ 'required' ], true);
                }
            }
            unset(
                $fieldObj['contentTable'], // SuperTable will auto-generate this for us.
                $fieldObj['columns'] // Cannot be set during first save, so we wont export this for now.
            );
        }

        $this->unmapSources($fieldObj);

        return $this->stripNulls($fieldObj);
    }
1371663
public function addBundle($bundle)
    {
        $bundle = $this->getBundleString($bundle);
        // not root bundle
        if (strpos($this->getKernal(), $bundle) === false) {
            $bundles = $this->getBundles();
            if (!in_array($bundle, $bundles)) {
                $bundles[] = $bundle;
                $this->setBundles($bundles);
            }
        }
    }
1278591
protected function processPackage(Package $package)
    {
        $extra = $package->getExtra();
        $files = isset($extra[self::EXTRA_OPTION_NAME]) ? $extra[self::EXTRA_OPTION_NAME] : null;
        $this->originalFiles[$package->getPrettyName()] = $files;

        if (is_array($files)) {
            $this->addFiles($package, $files);
        }
        if ($package->isRoot()) {
            $this->loadDotEnv($package);
            if (!empty($extra[self::EXTRA_DEV_OPTION_NAME])) {
                $this->addFiles($package, $extra[self::EXTRA_DEV_OPTION_NAME]);
            }
        }

        $aliases = $package->collectAliases();

        $this->builder->mergeAliases($aliases);
        $this->builder->setPackage($package->getPrettyName(), array_filter([
            'name' => $package->getPrettyName(),
            'version' => $package->getVersion(),
            'reference' => $package->getSourceReference() ?: $package->getDistReference(),
            'aliases' => $aliases,
        ]));
    }
362150
public function addBundle($name, array $deps)
    {
        if ($name == '') {
            throw new exception\InvalidArgumentException('The require.js bundle name must not be empty');
        }

        $this->bundles[$name] = [];
        $this->addToBundle($name, $deps);

        return $this;
    }
893945
public function setExtras(array $extra)
    {
        if (!empty($extra)) {
            $this->extras = array_merge($this->extras, $extra);
        }

        return $this;
    }
1274696
public function dumpAutoloads($extra = '')
    {
        $extra = $extra ? (array) $extra : [];

        $command = array_merge($this->findComposer(), ['dump-autoload'], $extra);

        $this->getProcess($command)->run();
    }
715824
protected function setIsSymlinkEnabled(array $extraConfigs)
    {
        if (isset($extraConfigs[SharedPackageInstaller::PACKAGE_TYPE]['symlink-enabled'])) {
            if (!is_bool($extraConfigs[SharedPackageInstaller::PACKAGE_TYPE]['symlink-enabled'])) {
                throw new \UnexpectedValueException('The configuration "symlink-enabled" should be a boolean');
            }

            $this->isSymlinkEnabled = $extraConfigs[SharedPackageInstaller::PACKAGE_TYPE]['symlink-enabled'];
        }
    }
1170768
public function getExtra($name)
    {
        if ($this->hasExtra($name)) {
            return $this->extras[$name];
        }

        throw new \InvalidArgumentException(sprintf('Extra with name "%s" is not defined', $name));
    }
922898
public function validateExcludedModules(array $excluded_modules) {
    $components = $this->componentDiscovery->getAll();

    // Can't exclude Lightning Core.
    unset($components['lightning_core']);

    // Can't exclude anything that isn't a Lightning component or sub-component.
    $invalid = array_diff($excluded_modules, array_keys($components));

    if ($invalid) {
      $error = sprintf(
        $this->trans('commands.lightning.subprofile.errors.invalid-exclusions'),
        Element::oxford($invalid)
      );

      throw new \InvalidArgumentException($error);
    }
  }
151947
public function build(array $extra, $baseDir)
    {
        $this->reset();

        $commitAuto = 'never';
        $commitBinFile = null;
        $commitMessage = 'Update dependencies';
        $gitlabHosts = [];
        $postUpdatePriority = -1;

        if (array_key_exists('commit-auto', $extra)) {
            if (in_array($extra['commit-auto'], self::$validCommitAutoValues, true)) {
                $commitAuto = $extra['commit-auto'];
            } else {
                $this->warnings[] = self::createWarningFromInvalidValue(
                    $extra,
                    'commit-auto',
                    $commitAuto,
                    sprintf('Valid options are "%s".', implode('", "', self::$validCommitAutoValues))
                );
            }
        }

        if (array_key_exists('commit-bin-file', $extra)) {
            if ($commitAuto === 'never') {
                $this->warnings[] = '"commit-bin-file" is specified but "commit-auto" option is set to "never". Ignoring.';
            } else {
                $file = realpath(
                    FileSystemHelper::isAbsolute($extra['commit-bin-file'])
                    ? $extra['commit-bin-file']
                    : $baseDir . '/' . $extra['commit-bin-file']
                );

                if (!file_exists($file)) {
                    $this->warnings[] = 'The file pointed by the option "commit-bin-file" was not found. Ignoring.';
                } else {
                    $commitBinFile = $file;
                }
            }
        } else {
            if ($commitAuto !== 'never') {
                $this->warnings[] = sprintf(
                    '"commit-auto" is set to "%s" but "commit-bin-file" was not specified.',
                    $commitAuto
                );
            }
        }

        if (array_key_exists('commit-message', $extra)) {
            if (strlen(trim($extra['commit-message'])) === 0) {
                $this->warnings[] = '"commit-message" is specified but empty. Ignoring and using default commit message.';
            } else {
                $commitMessage = $extra['commit-message'];
            }
        }

        if (array_key_exists('gitlab-hosts', $extra)) {
            if (!is_array($extra['gitlab-hosts'])) {
                $this->warnings[] = '"gitlab-hosts" is specified but should be an array. Ignoring.';
            } else {
                $gitlabHosts = (array) $extra['gitlab-hosts'];
            }
        }

        if (array_key_exists('post-update-priority', $extra)) {
            if (!preg_match('/^-?\d+$/', $extra['post-update-priority'])) {
                $this->warnings[] = '"post-update-priority" is specified but not an integer. Ignoring and using default commit event priority.';
            } else {
                $postUpdatePriority = (int) $extra['post-update-priority'];
            }
        }

        return new Config($commitAuto, $commitBinFile, $commitMessage, $gitlabHosts, $postUpdatePriority);
    }