Check if query is configured
@throws InvalidConfigException
552206
public function init()
    {
        if ($this->query === null) {
            throw new InvalidConfigException(get_class($this) . '::$query must be set.');
        }

        if ($this->formatData === null) {
            $this->formatData = function ($query, $columns) {
                $rows = [];
                foreach ($query->all() as $obj) {
                    $row = [];
                    foreach ($columns as $column) {
                    	if ($column['data']) {
		                    $value = ArrayHelper::getValue($obj, $column['data'], null);
		                    if (($pos = strrpos($column['data'], '.')) !== false) {
			                    $keys = explode('.', $column['data']);
			                    $a = $value;
			                    foreach (array_reverse($keys) as $key) {
				                    $a = [$key => $a];
			                    }
			                    $row[$keys[0]] = $a[$keys[0]];
		                    } else {
			                    $row[$column['data']] = $value;
		                    }
	                    }
                    }
                    $rows[] = $row;
                }

                return $rows;
            };
        }
    }
1272191
public function init()
    {
        if ($this->attribute === null) {
            throw new InvalidConfigException('Please specify the "attribute" property.');
        }

        if (!isset($this->options['id'])) {
            $this->options['id'] = $this->getMdeditorId();
        }
    }
297196
public function verifyConfig()
    {
        $keys = ['implementedFinders', 'implementedMethods'];
        foreach ($keys as $key) {
            if (!isset($this->_config[$key])) {
                continue;
            }

            foreach ($this->_config[$key] as $method) {
                if (!is_callable([$this, $method])) {
                    throw new Exception(sprintf('The method %s is not callable on class %s', $method, get_class($this)));
                }
            }
        }
    }
176701
public function verifySettings(string $endpoint)
    {
        if (!isset($this->endpointsConfiguration[$endpoint])) {
            throw new \InvalidArgumentException(sprintf('The endpoint "%s" is not configured.', $endpoint), 1461435428);
        }

        if (!isset($this->endpointsConfiguration[$endpoint]['schema']) && !isset($this->endpointsConfiguration[$endpoint]['querySchema'])) {
            throw new \InvalidArgumentException(sprintf('There is no root query schema configured for endpoint "%s".', $endpoint), 1461435432);
        }

        if (isset($this->endpointsConfiguration[$endpoint]['schema']) && !file_exists($this->endpointsConfiguration[$endpoint]['schema'])) {
            throw new \InvalidArgumentException(sprintf('The Schema file configured for endpoint "%s" does not exist at: "%s".', $endpoint, $this->endpointsConfiguration[$endpoint]['schema']), 1516719329);
        }
    }
84600
public function check()
    {
        $result = true;

        $configurationSettings = [
            'Database.Host',
            'Database.Username',
            'Database.Password',
            'Database.Port',
            'Database.Name',
        ];

        foreach ($configurationSettings as $setting) {
            if ($this->configuration->hasConfigurationKey($setting) === false) {
                $this->missingConfiguration[] = $setting;
                $result = false;
            }
        }

        return $result;
    }
1281535
protected function initialiseQuery()
    {
        // Join on base table and let lazy loading join subtables
        $baseClass = DataObject::getSchema()->baseDataClass($this->dataClass());
        if (!$baseClass) {
            throw new InvalidArgumentException("DataQuery::create() Can't find data classes for '{$this->dataClass}'");
        }

        // Build our intial query
        $this->query = new SQLSelect(array());
        $this->query->setDistinct(true);

        if ($sort = singleton($this->dataClass)->config()->get('default_sort')) {
            $this->sort($sort);
        }

        $baseTable = DataObject::getSchema()->tableName($baseClass);
        $this->query->setFrom("\"{$baseTable}\"");

        $obj = Injector::inst()->get($baseClass);
        $obj->extend('augmentDataQueryCreation', $this->query, $this);
    }
77504
private function _checkVariables() {
	    // Check to make sure that the $databaseComponent is a string
        if (! is_string($this->databaseComponent)) {
            throw new InvalidConfigException("Image Manager Component - Init: Database component '$this->databaseComponent' is not a string");
        }

        // Check to make sure that the $databaseComponent object exists
        if (Yii::$app->get($this->databaseComponent, false) === null) {
            throw new InvalidConfigException("Image Manager Component - Init: Database component '$this->databaseComponent' does not exists in application configuration");
        }

        // Check to make sure that the $databaseComponent is a yii\db\Connection object
        if (($databaseComponentClassName = get_class(Yii::$app->get($this->databaseComponent))) !== ($connectionClassName = Connection::className())) {
            throw new InvalidConfigException("Image Manager Component - Init: Database component '$this->databaseComponent' is not of type '$connectionClassName' instead it is '$databaseComponentClassName'");
        }
    }
1141524
private function validateRedirections()
    {
        foreach ($this->redirections as $redirection)
        {
            if(!(
                array_key_exists('source', $redirection)
                &&
                array_key_exists('target', $redirection)
                &&
                array_key_exists('type', $redirection)
            ))
            {
                throw new ConfigurationException("Invalid redirection line: " . implode(',', $redirection) . ".");
            }
        }
    }
667138
protected function prepareModels() {
		if(!$this->query instanceof QueryInterface) {
			throw new InvalidConfigException(
				'The "query" property must be an instance of a class that implements the '.
				'chsergey\rest\QueryInterface or its subclasses.'
			);
		}

		$query = clone $this->query;

		$this->setPagination([
			'pageSizeLimit' => [1, 1000]
		]);

		if (($pagination = $this->getPagination()) !== false) {
			$pagination->totalCount = $this->getTotalCount();
			$query->limit($pagination->getLimit())
				->offset($pagination->getOffset());
		}

		return $query->all();
	}
80425
public function init()
	{
		if (!in_array($this->extension, static::$ALLOWED_EXTENSIONS)) {
			$msg = Yii::t('app', 'Illegal extension {ext}, only these are allowed: {allowed}', [
				'ext'=>$this->extension,
				'allowed'=>implode(', ', static::$ALLOWED_EXTENSIONS),
			]);
			throw new InvalidConfigException($msg);
		}
	}
478866
private function prepareUpload()
    {
        $contextOptions = $this->getContextOptions();
        if (isset($contextOptions[$this->_protocol]['upload'])) {
            $upload = $contextOptions[$this->_protocol]['upload'];
            if (!$upload instanceof Upload) {
                throw new InvalidConfigException('"upload" context option should be an instance of "' . Upload::className() . '"');
            }
            $this->_upload = $upload;
            return true;
        }

        $collection = $this->fetchCollection();
        $this->_upload = $collection->createUpload(['document' => $this->_queryParams]);
        return true;
    }
56184
protected function isQueryAttribute()
    {
        if( $query = ($this->settings['query'] ?? NULL) )
        {
            $this->settings['getrow'] = Singleton::class('ZN\Database\DB')->query($query)->row();
        }
    }
1184085
@Override
	public void configure(Configuration parameters) {
		boolean needConfigure = isFieldNullOrEmpty(this.query) || isFieldNullOrEmpty(this.dbURL);
		if (needConfigure) {
			this.driverName = parameters.getString(DRIVER_KEY, null);
			this.username = parameters.getString(USERNAME_KEY, null);
			this.password = parameters.getString(PASSWORD_KEY, null);
			this.query = parameters.getString(QUERY_KEY, null);
			this.dbURL = parameters.getString(URL_KEY, null);
		}

		try {
			prepareQueryExecution();
		} catch (SQLException e) {
			throw new IllegalArgumentException("Configure failed:\t!", e);
		}
	}
908837
public function init()
    {
        parent::init();

        if ($this->connectorRoute === null) {
            throw new InvalidConfigException('Connector route must be specified.');
        }

        $this->settings['url'] = Url::toRoute($this->connectorRoute);

        if (!isset($this->settings['lang'])) {
            $this->settings['lang'] = Yii::$app->language;
        } elseif ($this->settings['lang'] === false) {
            unset($this->settings['lang']);
        }

        $this->settings['customData'] = [
            Yii::$app->request->csrfParam => Yii::$app->request->csrfToken,
        ];
    }
69218
private function validateConfig()
    {
        $mustBePositiveKeys = ['maxCyclesToWaitForSession', 'maxSessions', 'minSessions', 'sleepIntervalSeconds'];

        foreach ($mustBePositiveKeys as $key) {
            if ($this->config[$key] < 0) {
                throw new \InvalidArgumentException("$key may not be negative");
            }
        }

        if ($this->config['maxSessions'] < $this->config['minSessions']) {
            throw new \InvalidArgumentException('minSessions cannot exceed maxSessions');
        }

        if (isset($this->config['lock']) && !$this->config['lock'] instanceof LockInterface) {
            throw new \InvalidArgumentException(
                'The lock must implement Google\Cloud\Core\Lock\LockInterface'
            );
        }
    }
868469
public function is_configured() {
        if ($this->get_config('runningmethod') === 'commandline') {
            return (bool)$this->get_config('pathtoclam');
        } else if ($this->get_config('runningmethod') === 'unixsocket') {
            return (bool)$this->get_config('pathtounixsocket');
        }
        return false;
    }
677913
private function isValidConfigs(array $configs): void
    {
        $allowedConfigKeys = $this->getAllowedConfigKeys();
        if (!empty($configs)) {
            foreach ($configs as $key => $value) {
                if (!\in_array($key, $allowedConfigKeys, true)) {
                    throw new InvalidKeyException(sprintf(
                        '%s is not a valid key. configs must only contain "%s".',
                        $key,
                        implode(', ', $allowedConfigKeys)
                    ));
                }

                $this->isBool($key, $value);
                $this->isString($key, $value);
                $this->isValidNBest($key, $value);
            }
        }
    }