Process initializers

@param  Element $initializers
@return array
@throws InvalidConfig
430076
protected function processInitializers(Element $initializers) {
		$definitions = new stdClass();
		
		foreach ($initializers->getContent() as $initializer) {
			if ($initializer->getName() !== 'initializer') {
				throw new InvalidConfig('Unknown element "' . $initializers->getName() . '" in initializers', null, null, $initializer);
			}
				
			$initializerDefinition = $this->processInitializer($initializer);

			$id = isset($initializer->id)
				? $initializer->id
				: substr(md5(json_encode($initializerDefinition)), 24);

			if (! $this->override && isset($definitions->$id)) {
				throw new InvalidConfig('Initializer "' . $id . '" is already been set and cannot be overridden');
			}

			$definitions->$id = $initializerDefinition;
		}
		
		return $definitions;
	}
377185
protected function processConfiguration(array $configs) {
        $config = [];

        foreach ($configs as $group) {
            $config = array_extend_distinct($config, $group);
        }

        return $config;
    }
826611
private function loadConfig(array $configs, ContainerBuilder $container)
    {
        $configuration = new Configuration();
        $processedConfiguration = $this->processConfiguration($configuration, $configs);

        foreach ($processedConfiguration as $key => $value) {
            $container->setParameter(
                $this->getAlias().'.'.$key,
                $value
            );
        }
    }
53187
private function initializeConfig()
    {
        if (empty($this->config['url'])) {
            $this->config['url'] = static::$url;
        }

        $this->config['url'] = rtrim($this->config['url'], '/');

        if (filter_var($this->config['url'], FILTER_VALIDATE_URL) === false) {
            throw new InvalidConfigException('You must provide a valid URL in the config.');
        }
    }
340312
public function init()
    {
        if (empty($this->clientConfig['credentials'])) {
            throw new InvalidConfigException('Credentials are not set.');
        }

        if (empty($this->clientConfig['region'])) {
            throw new InvalidConfigException('Region is not set.');
        }

        if (empty($this->defaultBucket)) {
            throw new InvalidConfigException('Default bucket name is not set.');
        }

        foreach ($this->defaultComponentDefinitions() as $name => $definition) {
            $this->components[$name] = $this->components[$name] ?? $definition;
        }
    }
822831
public function init()
    {
        foreach (static::defaultConfig() as $key => $value) {
            if (!isset($this->{$key})) {
                $this->{$key} = $value;
            }
        }
        foreach (static::requiredConfig() as $key) {
            if (!isset($this->{$key})) {
                throw new InvalidConfigException(get_class($this) . " key provider requires '{$key}' config key");
            }
        }
        KeyProviderCollector::internalRegisterProvider($this);
    }
1164604
protected function processInitializer(Element $initializer) {
		$definition = new stdClass();
		
		if (isset($initializer->namespace)) {
			$definition->type      = 'namespace';
			$definition->namespace = $initializer->namespace;
		}
		else if (isset($initializer->class)) {
			$definition->type  = 'object';
			$definition->class = $initializer->class;
		}
		
		if ($initializer->factory === 'true') {
			$definition->factory = true;
		}
		
		$content = $initializer->getContent();
		
		if (! empty($content)) {
			$this->processDefinitionParameters($content, $definition);
		}
		
		return $definition;
	}
54913
protected function validateDefaultLocalization($localizations)
    {
        $result = false;
        foreach ($localizations as $localization) {
            if ($localization->isDefault()) {
                if ($result) {
                    throw new InvalidDefaultLocalizationException();
                }
                $result = true;
            }
        }

        return $result;
    }
1258064
function initializer()
    {
        if ($this->initializer)
            return $this->initializer;

        // ..

        $initializer = new InitializerAggregate($this);

        # attach defaults:
        $initializer->addCallable(function($instance, $self) {
            if ($instance instanceof iServicesAware)
                // Inject Service Container Inside
                $instance->setServices($self);
        }, 10000);

        return $this->initializer = $initializer;
    }
17091
@SuppressWarnings("unchecked")
    protected void processInitialCollectorManagerServices() throws InvalidSyntaxException {
        ServiceReference<CollectorManager>[] servRefs = (ServiceReference<CollectorManager>[])
                        bundleContext.getServiceReferences(CollectorManager.class.getName(), null);

        if (servRefs != null) {
            for (ServiceReference<CollectorManager> servRef : servRefs) {
            	setCollectorManagerPipeline(servRef);
            }
        }
    }
1208377
private function run_initializers()
    {
        $method_name = 'init';
        $cn = get_called_class();
        
        # Run ApplicationController's init method.
        if ($inits = $this->getAppControllersMethod($method_name)) {
            foreach ($inits as $init) {
                $init = $init->bindTo($this);
                $init();
            }
        }
        
        $method = $this->selfRefl->getMethod($method_name);
        if ($method->getDeclaringClass()->getName() == $cn) {
            $this->$method_name();
        }
    }
1136194
protected function initMethods()
    {
        if (empty($this->methods)) {
            return;
        }

        if (!is_array($this->methods)) {
            throw new InvalidConfigException('The "methods" option are not an array');
        }

        foreach ($this->methods as $methodName => $handler) {
            $function = $handler instanceof JsExpression ? $handler : new JsExpression($handler);
            $this->clientOptions['methods'][$methodName] = $function;
        }
    }
3717
protected function initializeProperties($properties = null)
    {
        $this->getPropertiesInfo();

        // Initialize the properties that were defined using the Initialize / InitializeObject annotations
        $initializeValueValidationEnabled = Configuration::isInitializeValuesValidationEnabled();
        foreach ($this->_initialPropertiesValues as $propertyName => $initialization) {
            $value = null;
            switch ($initialization['type']) {
                case 'initialize':
                    $value = $initialization['value'];
                    break;
                default:
                    $className = $initialization['value'];
                    $value = new $className();
                    break;
            }

            if ($initializeValueValidationEnabled) {
                $this->assertPropertyValue($propertyName, $value);
            }

            $this->$propertyName = $value;
            $this->updateInitializedPropertyValue($propertyName, $value);
        }

        // Initialize the propeties using given arguments
        if ($this->_initializationNeededArguments !== null && $properties !== null) {
            $numberOfNeededArguments = count($this->_initializationNeededArguments);

            MethodCallManager::assertArgsNumber($numberOfNeededArguments, $properties);

            for ($i = 0; $i < $numberOfNeededArguments; $i++) {
                $propertyName = $this->_initializationNeededArguments[$i];
                $argument = $properties[$i];

                $this->assertPropertyValue($propertyName, $argument);
                $this->$propertyName = $argument;
                $this->updateInitializedPropertyValue($propertyName, $argument);
            }
        }
    }
1109178
public function ElementsByName( $names )
	{
		if ( is_string( $names ) )
			$names = array_map( 'trim', explode( ",", $names ) );

		if ( ! is_array( $names ) )
			throw new Exception( 'InstanceElementsFilter::ElementsByName $names must be a string or array' );

		$names = array_flip( $names );
		return new InstanceElementsFilter( $this->instance, array_intersect_key( $this->elements, $names ) );
	}
137688
public function init()
    {
        if (empty($this->models) && !$this->modelClass) {
            throw new InvalidConfigException('You must at least specify "models" or "modelClass"');
        }

        if ($this->form !== null && !$this->form instanceof ActiveForm) {
            throw new InvalidConfigException('Property "form" must be an instance of yii\widgets\ActiveForm');
        }

        if (!is_array($this->models)) {
            throw new InvalidConfigException('Property "models" must be an array');
        }

        if ($this->models) {
            $modelClasses = [];
            foreach ($this->models as $model) {
                if (!$model instanceof Model) {
                    throw new InvalidConfigException('Model has to be an instance of yii\base\Model');
                }

                $modelClasses[get_class($model)] = true;
            }

            if (count($modelClasses) > 1) {
                throw new InvalidConfigException("You cannot use models of different classes");
            }

            $this->modelClass = key($modelClasses);
        }

        parent::init();
    }
193519
public function init(
        array $initial_services     = array(),
        array $services_providers   = array(),
        array $services_protected   = array()
    ) {
        // object can only be initialized once
        if (!is_object($this->_services)) {
            $this->_services                = new Collection();
            $this->_services_protected      = new Collection();
            $this->_services_providers      = new Collection();
            if (!empty($initial_services)) {
                foreach ($initial_services as $_name=>$_service) {
                    $this->setService($_name, $_service);
                }
            }
            if (!empty($services_providers)) {
                foreach ($services_providers as $_name=>$_provider) {
                    $this->setProvider($_name, $_provider);
                }
            }
            if (!empty($services_protected)) {
                foreach ($services_protected as $_name) {
                    $this->setProtected($_name);
                }
            }
        }
        return $this;
    }
676908
protected function validateInitializer()
    {
        if ($this->renderer === null) {
            $settingsInstance = $this->getSettingsInstance();

            if ($this->type === static::TYPE_EXCEL) {
                $initializerClass = $settingsInstance->getDefaultExcelInitializerClass();
            } elseif ($this->type === static::TYPE_PDF) {
                $initializerClass = $settingsInstance->getDefaultPDFInitializerClass();
            } else {
                $initializerClass = $settingsInstance->getDefaultInitializerClass();
            }

            $this->initializer = new $initializerClass;
        }
    }