@param $type
@param $config
@param IFlyWeightParser $parser

@return MapClosure|MapFunction|MapObject|mixed
323386
public static function make($type, $config, IFlyWeightParser $parser = null)
    {
        switch ($type) {
            case Map::TYPE_O:
                return new MapObject($config, $parser);
                break;
            case Map::TYPE_F:
                //return new MFunction($config);
                break;
            case Map::TYPE_LF:
                //return new LambdaFunction($config);
                break;
            default:
                throw new RouteException("Invalid Call type" . __METHOD__);
                break;
        }
    }
33038
public function create( $model, $config = [] ) {

		if( empty( $model->type ) ) {

			$model->type = CoreGlobal::TYPE_DEFAULT;
		}

		return parent::create( $model, $config );
	}
1309651
public static function findFeaturedByType( $type, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;
		$order		= isset( $config[ 'order' ] ) ? $config[ 'order' ] : [ 'name' => SORT_ASC  ];
		$limit 		= $config['limit'] ?? null;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'type=:type AND siteId=:siteId AND featured=1', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( $order )->limit($limit)->all();
		}
		else {

			return static::find()->where( 'type=:type AND featured=1', [ ':type' => $type ] )->orderBy( $order )->limit( $limit )->all();
		}
	}
674316
public static function createFromConfig($config)
    {
        $scaffolder = Injector::inst()->get(self::class);
        if (isset($config['types'])) {
            if (!ArrayLib::is_associative($config['types'])) {
                throw new InvalidArgumentException(
                    '"types" must be a map of class name to settings.'
                );
            }

            foreach ($config['types'] as $dataObjectClass => $settings) {
                $scaffolder->type($dataObjectClass)
                    ->applyConfig($settings);
            }
        }

        $queryMap = [
            'queries' => 'query',
            'mutations' => 'mutation',
        ];

        foreach ($queryMap as $group => $method) {
            if (isset($config[$group])) {
                if (!ArrayLib::is_associative($config[$group])) {
                    throw new InvalidArgumentException(
                        sprintf(
                            '"%s" must be a map of operation name to settings.',
                            $group
                        )
                    );
                }

                foreach ($config[$group] as $fieldName => $fieldSettings) {
                    if (!isset($fieldSettings['type'])) {
                        throw new InvalidArgumentException(
                            sprintf(
                                '"%s" must have a "type" field. See %s',
                                $group,
                                $fieldName
                            )
                        );
                    }

                    $scaffolder->$method($fieldName, $fieldSettings['type'])
                        ->applyConfig($fieldSettings);
                }
            }
        }

        return $scaffolder;
    }
1362781
protected function run(Config $config): ResultInterface
    {
        $includes = $config->compileIncludes();

        $constants = [];
        foreach ($includes as $key) {
            // phpcs:ignore WordPressVIPMinimum.Constants.ConstantString.NotCheckingConstantName
            $constants[$key] = defined($key)
                ? (string) constant($key)
                : '';
        }

        $duplicatedValues = array_values(
            array_diff_assoc(
                $constants,
                array_unique($constants)
            )
        );

        $duplicated = array_keys(
            array_filter($constants, function (string $value) use ($duplicatedValues): bool {
                return in_array($value, $duplicatedValues, true);
            })
        );

        if (! empty($duplicated)) {
            $messages = array_merge(['Salt constants are not unique(or not defined):'], $duplicated);

            return ResultFactory::makeFailure($this, $messages);
        }

        return ResultFactory::makeSuccess($this);
    }
1371207
public function create($type, $config)
    {
        $method = $config->get('Cache.DefinitionImpl');
        if ($method === null) {
            return new HTMLPurifier_DefinitionCache_Null($type);
        }
        if (!empty($this->caches[$method][$type])) {
            return $this->caches[$method][$type];
        }
        if (isset($this->implementations[$method]) &&
            class_exists($class = $this->implementations[$method], false)) {
            $cache = new $class($type);
        } else {
            if ($method != 'Serializer') {
                trigger_error("Unrecognized DefinitionCache $method, using Serializer instead", E_USER_WARNING);
            }
            $cache = new HTMLPurifier_DefinitionCache_Serializer($type);
        }
        foreach ($this->decorators as $decorator) {
            $new_cache = $decorator->decorate($cache);
            // prevent infinite recursion in PHP 4
            unset($cache);
            $cache = $new_cache;
        }
        $this->caches[$method][$type] = $cache;
        return $this->caches[$method][$type];
    }
1147693
public static function configure($config = [])
    {
        if (empty(static::$config)) {
            static::$config = $config;
        }

        if (!in_array($config['driver'], ["smtp", "mail"])) {
            throw new MailException("The type is not known.", E_USER_ERROR);
        }

        if ($config['driver'] == "mail") {
            if (!static::$instance instanceof Native) {
                static::$instance = new Native($config['mail']);
            }
        } else {
            if (!static::$instance instanceof Smtp) {
                static::$instance = new Smtp($config['smtp']);
            }
        }

        return static::$instance;
    }
1353472
protected function buildContainer($config)
    {
        $container = new ContainerBuilder(new ParameterBag($this->getParameters()));

        $this->prepareContainer($container);
        $this->getContainerLoader($container)->load($config);

        return $container;
    }
420215
public static function findByType( $type, $config = [] ) {

		$ignoreSite	= isset( $config[ 'ignoreSite' ] ) ? $config[ 'ignoreSite' ] : false;

		if( static::isMultiSite() && !$ignoreSite ) {

			$siteId	= isset( $config[ 'siteId' ] ) ? $config[ 'siteId' ] : Yii::$app->core->siteId;

			return static::find()->where( 'type=:type AND siteId=:siteId', [ ':type' => $type, ':siteId' => $siteId ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
		}
		else {

			return static::find()->where( 'type=:type', [ ':type' => $type ] )->orderBy( [ 'order' => SORT_ASC ] )->all();
		}
	}
1116263
protected <T> T map(Config config, Class<T> clazz) {
    return map(config, null, null, clazz);
  }
399234
public function load($resource, $type = null) 
    {
        $path = $this->locator->locate($resource);
        
        if (!stream_is_local($path)) {
            throw new \InvalidArgumentException(sprintf('This is not a local file "%s".', $path));
        }

        if (!file_exists($path)) {
            throw new \InvalidArgumentException(sprintf('File "%s" not found.', $path));
        }

        $returnArray = include $path;
        
        if(false === is_array($returnArray)) {
            throw ConfigException::configNotArray($path);
        }
        
        $this->loaded[$resource] = $path;
        
        return $returnArray;
    }
1253289
protected function fillType(KeyValueType $type, $config)
    {
        $parsed = $this->parseConfig($config);

        foreach ($parsed as $key=>$value) {
            $type[$key] = $parsed[$key];
        }

        return $type;
    }
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);

		}

	}
1195174
public function getGlobalBySlugType( $slug, $type, $config = [] ) {

		$modelClass = static::$modelClass;

		return $modelClass::findGlobalBySlugType( $slug, $type, $config );
	}
1200691
public static function generateObjectMap( $config = [] ) {

		$modelClass	= static::$modelClass;
		$modelTable = $modelClass::tableName();

		// map columns
		$key	= $config[ 'key' ] ?? 'id';
		$value	= static::$modelClass;

		// query generation
		$query		= $config[ 'query' ] ?? $value::find();
		$limit		= $config[ 'limit' ] ?? self::PAGE_LIMIT;
		$conditions	= $config[ 'conditions' ] ?? null;
		$filters	= $config[ 'filters' ] ?? null;

		// Conditions ----------

		if( isset( $conditions ) ) {

			foreach ( $conditions as $ckey => $condition ) {

				if( is_numeric( $ckey ) ) {

					$query->andWhere( $condition );

					unset( $conditions[ $ckey ] );
				}
			}

			$query->andWhere( $conditions );
		}

		$interfaces = class_implements( static::class );

		if( isset( $interfaces[ 'cmsgears\core\common\services\interfaces\base\IApproval' ] ) ) {

			$statusFilter = $modelClass::STATUS_TERMINATED;

			$query->andWhere( "$modelTable.status<$statusFilter" );
		}

		// Filters -------------

		if( isset( $filters ) ) {

			foreach ( $filters as $filter ) {

				$query	= $query->andFilterWhere( $filter );
			}
		}

		// Quering -------------

		$objects = $query->all();

		// Result --------------

		$map = [];

		foreach( $objects as $object ) {

			$map[ $object->$key ] = $object;
		}

		return $map;
	}
1352454
public function parseConfig($config) 
	{
    	if(isset($config['watermarkFile'])) {
			// This also call setWatermarkFullPath
			$this->openWatermark($config['watermarkFile']);
    	}
    	
    	if(isset($config['tmpDir'])) {
			$this->setWatermarkTmpDir($config['tmpDir']);
    	}
        
        return $this;
	}
404961
public static function queryByType( $parentId, $parentType, $type, $config = [] ) {

		$query = static::queryByParent( $parentId, $parentType, $config );

		$query->andWhere( 'type=:type', [ ':type' => $type ] );

		return $query;
	}