Build the widget config.

@param string $type   Widget type.
@param array  $config Configuration.

@return array
433178
private function buildWidgetConfig(string $type, array $config): array
    {
        $type            = substr($type, 3);
        $configKey       = 'form.layouts.' . $type . '.widgets';
        $bootstrapConfig = $this->environment->getConfig();
        $widgetConfig    = ArrayUtil::merge($this->widgetConfig, $bootstrapConfig->get('form.widgets'));

        if ($bootstrapConfig->has($configKey)) {
            $widgetConfig = ArrayUtil::merge($widgetConfig, $bootstrapConfig->get($configKey));
        }

        foreach (StringUtil::deserialize($config['widgets'], true) as $widget) {
            if ($widget['widget'] === '') {
                continue;
            }

            foreach ($this->sections as $section) {
                if ($widget[$section]) {
                    $widgetConfig[$widget['widget']]['templates'][$section] = $widget[$section];
                }
            }
        }

        return $widgetConfig;
    }
571848
public function renderWidget( $config = [] ) {

		$commentProperties = CommentProperties::getInstance();

		// Comments are disabled
		if( $this->type == ModelComment::TYPE_COMMENT && !$commentProperties->isComments() ) {

			return;
		}

		return parent::renderWidget( $config );
	}
601441
public function renderWidget( $config = [] ) {

		$this->links = array_flip( $this->links );

		$widgetHtml = $this->render( $this->template, [ 'widget' => $this ] );

		if( $this->wrap ) {

			return Html::tag( 'div', $widgetHtml, $this->options );
		}

		return $widgetHtml;
	}
823526
public function build(array $config)
    {
        $output = array();

        // Fix path in output dir
        if ('/' !== substr($config['output_dir'], -1) && strlen($config['output_dir']) > 0) {
            $config['output_dir'] .= '/';
        }

        // changed from css_preprocessor to css_preprocessor for 3.0
        if (in_array($config['css_preprocessor'], array('sass', 'scssphp'))) {
            $output['bootstrap_css'] = $this->buildCssWithSass($config);
        } elseif ('none' !== $config['css_preprocessor']) {
            $output['bootstrap_css'] = $this->buildCssWithLess($config);
        } else {
            $output['bootstrap_css'] = $this->buildCssWithoutLess($config);
        }

        $output['bootstrap_js'] = $this->buildJs($config);
        $output['jquery'] = $this->buildJquery($config);

        return $output;
    }
123254
private function __buildConfig(array $config)
    {
        foreach ($config as $key => $conf) {
            if ($key == 'driver') {
                $this->rawConfig['type'] = strtolower($conf);
                continue;
            }

            if (!array_key_exists($key, $this->rawConfig)) {
                $this->error->setMessage(sprintf(
                    "invalid config '%s', allowed config are: %s",
                    $key, implode(', ', array_keys($this->rawConfig))
                ));
                break;
            }

            $this->rawConfig[$key] = $conf;
        }

        if (!$this->error->hasError() && !$this->hasDriver($this->getType()) && !$this->preventNoLocalDriver) {
            $this->error->setMessage(sprintf(
                "Driver '%s' not available. Please choose one of: '%s'. ".
                'Or register new ConnectionString class by implements %s.',
                $this->getType(),
                implode("', '", $this->getAvailableDrivers()),
                ConnectionStringInterface::class
            ));
        }
    }
496436
protected function parseConfig(array $config): array
    {
        $result = [];
        foreach ($config as $key => $type) {
            if (\is_array($type)) {
                if ($arrayOfType = $this->factory->checkArrayOfType($type)) {
                    $result[$key] = $arrayOfType;
                } else {
                    $result[$key] = new self($type, $this->factory, $this->strict);
                }
            } elseif ($type instanceof CastInterface) {
                $result[$key] = $type;
            } else {
                $result[$key] = $this->factory->createType($type);
            }
        }

        return $result;
    }
803405
public function factory($type, array $config)
    {
        $this->setFactoryCreationOptions($type, $config);

        return $this->get($type, $config, false);
    }
14014
public function mergeConfig($configA, $configB)
    {
        $configA = $this->makeConfig($configA);

        $configB = $this->makeConfig($configB);

        return (object) array_merge((array) $configA, (array) $configB);
    }
1275277
public function beginWidget($widget, $config = [])
    {
        $widget = $this->resolveClassName($widget);
        $this->widgets[] = $widget;
        return $this->call($widget, 'begin', [
            $config,
        ]);
    }
71523
protected function buildBootstrapJs(array $config)
    {
        $path = !in_array($config['less_filter'], array('sass', 'scssphp')) ? "bower_components/bootstrap/js" : "bower_components/bootstrap-sass-official/assets/javascripts/bootstrap";

        return array(
            'inputs' => array(
                $this->normalizePath($config['bootswatch']['path'], $path, '/transition.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/alert.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/button.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/carousel.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/collapse.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/dropdown.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/modal.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/tooltip.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/popover.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/scrollspy.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/tab.js'),
                $this->normalizePath($config['bootswatch']['path'], $path, '/affix.js'),
                $this->normalizePath(dirname(__FILE__).'/../../Resources/js/bc-bootstrap-collection.js'),
            ),
            'output' => $this->normalizePath(isset($config['output_dir']) ? array($config['output_dir'], 'js/bootstrap.js') : 'js/bootstrap.js')
        );
    }
125677
public function renderWidget( $config = [] ) {

		$containerHtml	= $this->container ? $this->renderContainer( $config ) : null;

		$draggerHtml	= $this->dragger ? $this->renderDragger( $config ) : null;

		$chooserHtml	= $this->chooser ? $this->renderChooser( $config ) : null;

		$preloaderHtml	= $this->preloader ? $this->renderPreloader( $config ) : null;

		$infoHtml		= $this->info ? $this->renderInfo( $config ) : null;

		$fieldsHtml		= $this->fields ? $this->renderFields( $config ) : null;

		$formHtml		= $this->form ? $this->renderForm( $config, [ 'infoHtml' => $infoHtml, 'fieldsHtml' => $fieldsHtml ] ) : null;

		$uploaderView	= CodeGenUtil::isAbsolutePath( $this->uploaderView ) ? $this->uploaderView : "$this->template/$this->uploaderView";

		$widgetHtml = $this->render( $uploaderView, [
			'widget' => $this,
			'containerHtml' => $containerHtml,
			'draggerHtml' => $draggerHtml,
			'chooserHtml' => $chooserHtml,
			'preloaderHtml' => $preloaderHtml,
			'infoHtml' => $infoHtml,
			'fieldsHtml' => $fieldsHtml,
			'formHtml' => $formHtml
		] );

		if( $this->wrap ) {

			return Html::tag( $this->wrapper, $widgetHtml, $this->options );
		}

		return $widgetHtml;
	}
13866
public function renderWidget( $config = [] ) {

		$commentProperties = CommentProperties::getInstance();

		$this->allFields	= $commentProperties->isAllFields();
		$this->labels		= $commentProperties->isLabels();

		$user = Yii::$app->user->getIdentity();

		// Comments are disabled by admin
		if( !$commentProperties->isComments() ) {

			return;
		}

		// User is not logged in and public comments are disabled by admin for whole app
		if( !isset( $user ) && $commentProperties->isUserComments() ) {

			return;
		}

		$widgetHtml = $this->render( $this->template, [ 'widget' => $this ] );

		if( $this->wrap ) {

			return Html::tag( 'div', $widgetHtml, $this->options );
		}

		return $widgetHtml;
	}
505641
protected function getReadWriteConfig( array $config, $type )
	{
		if ( isset( $config[$type][0] ) )
			return $config[$type][array_rand( $config[$type] )];

		return $config[$type];
	}
106371
public function addFromConfig(array $config)
    {
        foreach ($config as $name => $data) {
            $params     = isset($data['params']) ? $data['params'] : array();
            $parameters = array();
            foreach ($params as $nameParam => $param) {
                if (empty($params['type'])) {
                    $params['type'] = 'string';
                }

                switch ($param['type']) {

                    case 'int':
                        $param['type'] = Parameter::TYPE_INTEGER;
                        break;

                    case 'mixed':
                        $param['type'] = Parameter::TYPE_MIXED;
                        break;

                    case 'string':
                        $param['type'] = Parameter::TYPE_STRING;
                        break;

                    default:
                        // Consider  current value as regexp
                }
                $parameters[$nameParam] = new Parameter($nameParam, $param['type'], (bool) $param['mandatory']);
            }
            $this->add(new Route($name, $data['route'], $data['controller'], $parameters));
        }

        return $this;
    }
61870
public function build(array $config, ContainerInterface $container = null)
    {
        $dispatcher = new Dispatcher($container);
        foreach ((array) $config as $name => $listeners) {
            foreach ($listeners as $listener) {
                if (is_callable($listener)) {
                    $dispatcher->register($name, $listener);
                    continue;
                }

                $listener = $this->applyDefaults($listener);

                $dispatcher->register(
                    $name,
                    $this->buildDefinition($listener)
                );
            }
        }

        return $dispatcher;
    }
163115
private function buildFirstDimensionOfContactsArray($type, $config)
    {
        $contacts = [];
        $websites = $this->helper->getWebsites(true);
        foreach ($websites as $website) {
            if (strpos($type, self::ORDER_STATUS_AUTOMATION) !== false) {
                $configValue = $this->helper->serializer->unserialize(
                    $this->helper->getWebsiteConfig($config, $website)
                );

                if (is_array($configValue) && !empty($configValue)) {
                    foreach ($configValue as $one) {
                        if (strpos($type, $one['status']) !== false) {
                            $contacts[$website->getId()]['programId']
                                = $one['automation'];
                        }
                    }
                }
            } else {
                $contacts[$website->getId()]['programId']
                    = $this->helper->getWebsiteConfig($config, $website);
            }
        }
        return $contacts;
    }
242010
private function buildHorizontalConfig(array $config): array
    {
        $horizontalConfig = $this->environment->getConfig()->get('form.layouts.horizontal.classes', []);

        foreach (['row', 'label', 'control', 'offset'] as $key) {
            if (!empty($config['bs_' . $key])) {
                $horizontalConfig[$key] = $config['bs_' . $key];
            }
        }

        return $horizontalConfig;
    }