Install remote plugin or theme.

@param string $type
@param array  $config

@return bool
777071
public function install( $type, $config = null ) {
		$this->set_install_post_data( $config );

		if ( isset( $_POST['option_page'] ) && 'github_updater_install' === $_POST['option_page'] ) {
			if ( empty( $_POST['github_updater_branch'] ) ) {
				$_POST['github_updater_branch'] = 'master';
			}

			// Exit early if no repo entered.
			if ( empty( $_POST['github_updater_repo'] ) ) {
				echo '<h3>';
				esc_html_e( 'A repository URI is required.', 'github-updater' );
				echo '</h3>';

				return false;
			}

			// Transform URI to owner/repo.
			$headers                      = $this->parse_header_uri( $_POST['github_updater_repo'] );
			$_POST['github_updater_repo'] = $headers['owner_repo'];

			self::$install         = $this->sanitize( $_POST );
			self::$install['repo'] = self::$install['github_updater_install_repo'] = $headers['repo'];

			/*
			 * Create GitHub endpoint.
			 * Save Access Token if present.
			 * Check for GitHub Self-Hosted.
			 */
			if ( 'github' === self::$install['github_updater_api'] ) {
				self::$install = Singleton::get_instance( 'API\GitHub_API', $this, new \stdClass() )->remote_install( $headers, self::$install );
			}

			/*
			 * Create Bitbucket endpoint and instantiate class Bitbucket_API.
			 * Save private setting if present.
			 * Ensures `maybe_authenticate_http()` is available.
			 */
			if ( 'bitbucket' === self::$install['github_updater_api'] ) {
				$this->load_authentication_hooks();
				if ( self::$installed_apis['bitbucket_api'] ) {
					self::$install = Singleton::get_instance( 'API\Bitbucket_API', $this, new \stdClass() )->remote_install( $headers, self::$install );
				}

				if ( self::$installed_apis['bitbucket_server_api'] ) {
					self::$install = Singleton::get_instance( 'API\Bitbucket_Server_API', $this, new \stdClass() )->remote_install( $headers, self::$install );
				}
			}

			/*
			 * Create GitLab endpoint.
			 * Save Access Token if present.
			 * Check for GitLab Self-Hosted.
			 */
			if ( 'gitlab' === self::$install['github_updater_api'] ) {
				if ( self::$installed_apis['gitlab_api'] ) {
					self::$install = Singleton::get_instance( 'API\GitLab_API', $this, new \stdClass() )->remote_install( $headers, self::$install );
				}
			}

			/*
			 * Create Gitea endpoint.
			 * Save Access Token if present.
			 */
			if ( 'gitea' === self::$install['github_updater_api'] ) {
				if ( self::$installed_apis['gitea_api'] ) {
					self::$install = Singleton::get_instance( 'API\Gitea_API', $this, new \stdClass() )->remote_install( $headers, self::$install );
				}
			}

			/*
			 * Install from Zipfile.
			 */
			if ( 'zipfile' === self::$install['github_updater_api'] ) {
				self::$install = Singleton::get_instance( 'API\Zipfile_API', $this )->remote_install( $headers, self::$install );
			}

			if ( isset( self::$install['options'] ) ) {
				$this->save_options_on_install( self::$install['options'] );
			}

			$url      = self::$install['download_link'];
			$upgrader = $this->get_upgrader( $type, $url );

			// Install the repo from the $source urldecode() and save branch setting.
			if ( $upgrader && $upgrader->install( $url ) ) {
				Singleton::get_instance( 'Branch', $this )->set_branch_on_install( self::$install );
			} else {
				return false;
			}
		}

		return true;
	}
805199
private function buildFallbackConfig(string $type, array $config): array
    {
        $type           = substr($type, 3);
        $fallbackConfig = $this->environment->getConfig()->get('form.layouts.' . $type, []);
        $fallbackConfig = ArrayUtil::merge($this->fallbackConfig, $fallbackConfig);

        foreach ($this->sections as $section) {
            $name = 'fallback' . ucfirst($section);

            if ($config[$name]) {
                $fallbackConfig['templates'][$section] = $config[$name];
            }
        }

        return $fallbackConfig;
    }
722372
protected static function addRedirectUriToServiceConfig(array $config)
    {
        if (!empty($config['constructor']) && is_array($config['constructor'])) {
            $key = key($config['constructor']); // Key may be non-numeric

            if (!isset($config['constructor'][$key]['redirectUri'])) {
                $config['constructor'][$key]['redirectUri'] = static::getRedirectUri();
            }
        }

        return $config;
    }
211189
public function send(string $type, array $options = []): bool
    {
        $type = $this->typeRegistry->get($type);
        $builder = MessageBuilder::fromType($type, $options);
        $message = ResolvedMessage::fromBuilder($builder);

        return $this->driver->send($message);
    }
805554
public static function installComposerPackage($project, $type='master')
    {
        $path = static ::getPackagePath($project);

        self::copyAssets($project);
        self::runMigrations($project, ['blend_modx_migration_dir' => $path], 'up', $type);
    }
9448
protected function prepareLabel($type, array $config, array $parentConfig)
    {
        return $label = isset($config['label'])
            ? $config['label']
            : 'lug.'.$this->buildResource($parentConfig)->getName().'.'.$type.'.'.$config['name'];
    }
557560
public function add(array $config) : self
    {
        $this->config = array_replace_recursive($this->config, $config);

        return $this;
    }
203971
protected function load($config = array())
	{
		// Check whether editor is already loaded
		if (!is_null($this->editor))
		{
			return;
		}

		// Build the path to the needed editor plugin
		$name = (string) preg_replace('/[^A-Z0-9_\.-]/i', '', $this->name);
		$name = ltrim($name, '.');

		$path = PATH_APP . '/plugins/editors/' . $name . '/' . $name . '.php';
		if (!is_file($path))
		{
			$path = PATH_CORE . '/plugins/editors/' . $name . '/' . $name . '.php';
			if (!is_file($path))
			{
				\Notify::error(Lang::txt('JLIB_HTML_EDITOR_CANNOT_LOAD'));
				return false;
			}
		}

		// Require plugin file
		require_once $path;

		// Get the plugin
		$plugin = Plugin::byType('editors', $this->name);

		$params = new Registry($plugin->params);
		$params->merge($config);

		$plugin->params = $params;

		// Build editor plugin classname
		$name = 'plgEditor' . $this->name;

		if ($this->editor = new $name($this, (array) $plugin))
		{
			// Load plugin parameters
			$this->initialise();

			Plugin::import('editors-xtd');
		}
	}
5271
function configure($config = []) {
    $this->config = array_replace_recursive($this->config, $this->modes[@$config['mode'] ?: $this->config['mode']]);
    
    $this->config = array_replace_recursive($this->config, $config);
    
    return $this;
  }
1105284
protected function loadExtensions(Config $config)
    {
        $uses = $config->get('uses', []);

        foreach ($uses as $use => $useSettings) {
            $this->loadExtension($use, $useSettings, $config);
        }

        return $this;
    }
912055
public function configureAsseticBundle(ContainerBuilder $container, array $config)
    {
        foreach (array_keys($container->getExtensions()) as $name) {
            switch ($name) {
                case 'assetic':
                    // Add jQuery in assets
                    $this->addJqueryInAssetic($container, $config['assets']['jquery']);

                    // Add Twitter Bootstrap assets
                    $this->addTwbsInAssetic($container, $config['assets']['twbs']);

                    // Add jQuery UI in assets
                    if (isset($config['assets']['jqueryui'])) {
                        $this->addJqueryUIInAssetic($container, $config['assets']['jqueryui']);
                    }

                    // Add select2 files
                    if (isset($config['assets']['select2'])) {
                        $this->addSelect2InAssetic($container, $config['assets']['select2']);
                    }

                    // Add Basinga js translation in assets
                    if (isset($config['assets']['bazinga_js_translation'])) {
                        $this->addBazingaJsTranslationInAssetic($container, $config['assets']['bazinga_js_translation']);
                    }

                    // Add Speaking URL in assets
                    if (isset($config['assets']['speakingurl'])) {
                        $this->addSpeakingURLInAssetic($container, $config['assets']['speakingurl']);
                    }

                    // Add TinyMCE in assets
                    if (isset($config['assets']['tinymce'])) {
                        $this->addTinyMCEInAssetic($container, $config['assets']['tinymce']);
                    }

                    // Add jQueryTagsInput in assets
                    if (isset($config['assets']['jquery_tags_input'])) {
                        $this->addJqueryTagsInputInAssetic($container, $config['assets']['jquery_tags_input']);
                    }

                    // Add PrismJS in assets
                    if (isset($config['assets']['prism_js'])) {
                        $this->addPrismJSInAssetic($container, $config['assets']['prism_js']);
                    }
                    break;
            }
        }
    }
1013204
protected function setup(array $config = [])
    {
        if (!isset($config['data_provider'])) {
            throw new Exception(translate('{data_provider} must be a DatapPovider objetc'), 500, Exception::BADARGUMENTS);
        } elseif (isset($config['data_provider']) && !($config['data_provider'] instanceof DataProviderInterface)) {
            throw new Exception(translate('{data_provider} must be a DatapPovider objetc'), 500, Exception::BADARGUMENTS);
        }

        if (!isset($config['columns'])) {
            throw new Exception(translate('{columns} must be an array type Column[]'), 500, Exception::BADARGUMENTS);
        }

        parent::setup($config);

        $this->setupColumns();
    }
237295
public function configure($config)
    {
        foreach ((array)$config as $key => $value) {
            $this->setConfig($key, $value);
        }
    }
1133971
private function configure(array $config = [])
    {
        foreach ($config as $property => $value) {
            if (property_exists($this, $property)) {
                $this->{$property} = $value;
            }
        }
    }
470202
public static function create($type = null, array $config = []) {

	    if(!$type) {

	        if(!isset($config['dsn'])) {
	            throw new \Exception('No database type defined.');
            }

            if(preg_match('/^([a-z0-9]+):/i', trim($config['dsn']), $matches)) {
                $type = $matches[1];
            }
            else {
                throw new \Exception('No driver found in DSN.');
            }

        }

		$type = strtolower($type);

		if($type === 'propel') {

			// check whether Propel is available (assume Propel2)

            if(!class_exists('\\Propel\\Runtime\\Propel')) {
                throw new \Exception('Propel is configured as driver for vxPDO but not available in this application.');
            }

            $serviceContainer = \Propel\Runtime\Propel::getServiceContainer();

            // retrieve adapter information

            $adapterName = $serviceContainer->getAdapterClass();
            $dsnName = $serviceContainer->getDefaultDatasource();

            /* @var $connection \Propel\Runtime\Connection\ConnectionInterface */

            $connection = \Propel\Runtime\Propel::getConnection();

            if(!in_array($adapterName, ['mysql', 'pgsql'])) {

                throw new \Exception(sprintf("vxPDO accepts only mysql and pgsql as established connection drivers. The configured Propel connection '%s' uses '%s'.", $dsnName, $adapterName));

			}

			// @todo fugly like hell - perhaps some more concise solution exists

            preg_match('/dbname=([^;]+)/i', \Propel\Runtime\Propel::getConnectionManager($dsnName)->getConfiguration()['dsn'], $matches);
            $dbName = $matches[1] ?? '';

            $pdoConnection = new Propel2ConnectionWrapper($connection);
            $pdoConnection->setName($dsnName);
            $pdoConnection->setDbName($dbName);

            $className =
                __NAMESPACE__ .
                '\\Adapter\\' .
                ucfirst($adapterName);

            /* @var $vxPDO DatabaseInterface */

            $vxPDO = new $className();
            $vxPDO->setConnection($pdoConnection);

            return $vxPDO;

		}

		else {

			$className =
				__NAMESPACE__ .
				'\\Adapter\\' .
				ucfirst($type);
	
			// check whether driver is available
				
			if(!class_exists($className)) {
	
				throw new ConfigException(sprintf("No class for driver '%s' supported.", $type));
	
			}
				
			return new $className($config);

		}

	}
622603
protected function shouldProceedWithInstall( InputInterface $input, OutputInterface $output, $config ) {
		$helper = $this->getHelper( 'question' );

		$output->writeln( 'Configuration:' );

		$output->writeln(
			str_pad( 'Clean composer.json: ', 25 )  .
			( $config['remove_composer_author_information'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln(
			str_pad( 'Install Carbon Fields: ', 25 )  .
			( $config['install_carbon_fields'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln(
			str_pad( 'Install CSS Framework: ', 25 ) .
			'<info>' . $config['install_css_framework'] . '</info>'
		);

		$output->writeln(
			str_pad( 'Install Font Awesome: ', 25 ) .
			( $config['install_font_awesome'] ? '<info>Yes</info>' : '<comment>No</comment>' )
		);

		$output->writeln( '' );

		$question = new ConfirmationQuestion(
			'Proceed with installation? <info>[Y/n]</info> ',
			true
		);

		$proceed = $helper->ask( $input, $output, $question );
		$output->writeln( '' );

		return $proceed;
	}
185215
public function setupPlugin(array $config = []): void
	{
		if (!$this->defaults) return;
		$this->setupConfig($this->defaults, $config);
	}