Function setConfig

Cài đặt cấu hình gửi mail

@author: 713uk13m <dev@nguyenanhung.com>
@time  : 10/11/18 15:08

@param array $config mảng dữ liệu chứa thông tin config

@see   Repository/config/example_config_mail.php
551588
public function setConfig($config = [])
    {
        $this->config = $config;
        $this->debug->debug(__FUNCTION__, 'setConfig: ', $this->config);
    }
434243
public function setConfig(array $config, $file = null)
    {
        $file = !empty($file) ? $file : $this->fileCache;
        if (file_exists($file)) {
            unlink($file);
        }
        (new PhpArray())
                ->setUseBracketArraySyntax(true)
                ->toFile($file, $config);
    }
556728
private function setConfig($config)
    {
        $this->securityLevel = $config->config['project']['security_level'];
        if ($config->config['config']) {
            foreach ($config->config['config'] as $k => $v) {
                $this->log->debug("[ CONFIG Params ]" . $k . ": " . $v, []);
                $this->config->$k = $this->setSecurityLevel($v);
                $this->parameters["config"][$k] = $this->setSecurityLevel($v);
            }
        }

    }
1037344
public function setBaseConfig(array $config)
    {
        parent::setBaseConfig($config);

        if (!$config['group_column']) {
            throw new DcGeneralException(__CLASS__ . ' needs a grouping column.', 1);
        }
        $this->strGroupCol = $config['group_column'];

        if ($config['sort_column']) {
            $this->strSortCol = $config['sort_column'];
        }
    }
6708
public function initialize(array $config)
    {
        parent::initialize($config);

        $this->setEmailObject(new Email($this->config('config')));
    }
322728
private function setConfig($config)
    {
        $allowedConfigKeys = [
            'alias',
            'async',
            'database',
            'host',
            'iterable_multibulk',
            'options',
            'password',
            'path',
            'port',
            'persistent',
            'profile',
            'timeout',
            'read_write_timeout',
            'scheme',
            'throw_errors',
            'weight',
        ];

        foreach ($config as $param => $server) {
            if (is_array($server)) {
                foreach (array_keys($server) as $key) {
                    if (!in_array($key, $allowedConfigKeys)) {
                        throw new RedisMalformedConfigException();
                    }
                }
            }

            if (!is_array($server) && !in_array($param, $allowedConfigKeys)) {
                throw new RedisMalformedConfigException();
            }
        }

        $this->config = $config;
    }
712443
public static function setConfiguration($config)
	{
		if(!is_array($config))
			throw new ConfigurationException('Configuration needs to be an array');
		
		if(array_key_exists('primaryGSLSNode')) self::$primaryGSLSNode = $config['primaryGSLSNode'];
		if(array_key_exists('secondaryGSLSNode')) self::$secondaryGSLSNode = $config['secondaryGSLSNode'];
		
		if(array_key_exists('apiPath')) self::$apiPath = $config['apiPath'];
		if(array_key_exists('timezone')) self::$timezone = $config['timezone'];
		if(array_key_exists('verbose')) self::$verbose = $config['verbose'];
		if(array_key_exists('curlVerbose')) self::$curlVerbose = $config['curlVerbose'];
		if(array_key_exists('requestTimeout')) self::$requestTimeout = $config['requestTimeout'];
		if(array_key_exists('gslsTimeout')) self::$gslsTimeout = $config['gslsTimeout'];
		if(array_key_exists('logfile')) self::$logfile = $config['logfile'];
	}
1142485
public function setConfig(array $config)
    {
        if (!isset($config['thumbnailer'])) {
            $this->_thumbnailer = new Thumbnailer();
        } elseif (class_exists($config['thumbnailer'])) {
            $this->_thumbnailer = new $config['thumbnailer'];
        } else {
            throw new ConfigurationException('Class ' . $config['thumbnailer'] . ' does not exist.');
        }

        if (!($this->_thumbnailer instanceof ThumbnailerInterface)) {
            throw new ConfigurationException('Class ' . get_class($this->_thumbnailer) . ' must implement the interface \ysaroka\autothumb\ThumbnailerInterface.');
        }

        if (!isset($config['document_root'])) {
            throw new ConfigurationException('"document_root" key is required.');
        }

        if (!is_dir(realpath($config['document_root']))) {
            throw new ConfigurationException('"document_root": directory "' . $config['document_root'] . '" does not exist.');
        }

        if (!isset($config['types']) || count($config['types']) == 0) {
            throw new ConfigurationException('"types" key is required and should not be empty.');
        }

        foreach ($config['types'] as $type => $params) {
            if (!preg_match('#^[\w\d]+$#', $type)) {
                throw new ConfigurationException('"type": type name "' . $type . '" must contain only words and numbers.');
            }

            if (!isset($params['width'])) {
                $config['types'][$type]['width'] = 100;
            }

            if (!isset($params['height'])) {
                $config['types'][$type]['height'] = 100;
            }

            if (!isset($params['crop'])) {
                $config['types'][$type]['crop'] = true;
            }

            if (!isset($params['stretch'])) {
                $config['types'][$type]['stretch'] = false;
            }

            if (!isset($params['watermark'])) {
                $config['types'][$type]['watermark'] = false;
            } elseif (file_exists($params['watermark']) && !is_dir($params['watermark'])) {
                $config['types'][$type]['watermark'] = realpath($params['watermark']);
                if (isset($params['watermark_pos']) && defined('\ysaroka\autothumb\ThumbnailerInterface::POS_' . strtoupper($params['watermark_pos']))) {
                    $config['types'][$type]['watermark_pos'] = constant('\ysaroka\autothumb\ThumbnailerInterface::POS_' . strtoupper($params['watermark_pos']));
                } else {
                    $config['types'][$type]['watermark_pos'] = ThumbnailerInterface::POS_BOTTOM_RIGHT;
                }
            } else {
                throw new ConfigurationException('Image file "watermark": "' . $params['watermark'] . '" for type "' . $type . '" does not exist.');
            }
        }

        if (isset($config['allowed_extensions']) && is_array($config['allowed_extensions']) && count($config['allowed_extensions']) > 0) {
            $this->_allowedExtensions = $config['allowed_extensions'];
        }

        $this->_documentRoot = realpath($config['document_root']);
        $this->_types = $config['types'];

        return $this;
    }
759597
public function configure(array $config)
    {
        return $this
            ->setGLSShipmentDeposit($config[Config::T8700])
            ->setCustomerCode($config[Config::T8915])
            ->setContactId($config[Config::T8914])
            ->clean();
    }
794634
public static function setConfig($config = [])
    {
        if (!is_array($config)) {
            return false;
        }
        self::$config = array_merge(self::$config, $config);
        return true;
    }
326517
public final function set_config($config) {
        global $DB;
        foreach ($config as $key => $value) {
            // try set it in $this first
            try {
                $this->set($key, $value);
                continue;
            } catch (portfolio_exception $e) { }
            if (!in_array($key, $this->get_allowed_config())) {
                $a = (object)array('property' => $key, 'class' => get_class($this));
                throw new portfolio_export_exception($this->get('exporter'), 'invalidconfigproperty', 'portfolio', null, $a);
            }
            if (!isset($this->config->{$key})) {
                $DB->insert_record('portfolio_instance_config', (object)array(
                    'instance' => $this->id,
                    'name' => $key,
                    'value' => $value,
                ));
            } else if ($this->config->{$key} != $value) {
                $DB->set_field('portfolio_instance_config', 'value', $value, array('name' => $key, 'instance' => $this->id));
            }
            $this->config->{$key} = $value;
        }
    }
294508
protected function _applyConfig($config)
    {
        if (is_string($config)) {
            $name = $config;
            $config = static::getConfig($name);
            if (empty($config)) {
                throw new InvalidArgumentException(sprintf('Unknown email configuration "%s".', $name));
            }
            unset($name);
        }

        $this->_profile = array_merge($this->_profile, $config);

        $simpleMethods = [
            'from', 'sender', 'to', 'replyTo', 'readReceipt', 'returnPath',
            'cc', 'bcc', 'messageId', 'domain', 'subject', 'attachments',
            'transport', 'emailFormat', 'emailPattern', 'charset', 'headerCharset'
        ];
        foreach ($simpleMethods as $method) {
            if (isset($config[$method])) {
                $this->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (empty($this->headerCharset)) {
            $this->headerCharset = $this->charset;
        }
        if (isset($config['headers'])) {
            $this->setHeaders($config['headers']);
        }

        $viewBuilderMethods = [
            'template', 'layout', 'theme'
        ];
        foreach ($viewBuilderMethods as $method) {
            if (array_key_exists($method, $config)) {
                $this->viewBuilder()->{'set' . ucfirst($method)}($config[$method]);
            }
        }

        if (array_key_exists('helpers', $config)) {
            $this->viewBuilder()->setHelpers($config['helpers'], false);
        }
        if (array_key_exists('viewRender', $config)) {
            $this->viewBuilder()->setClassName($config['viewRender']);
        }
        if (array_key_exists('viewVars', $config)) {
            $this->set($config['viewVars']);
        }
    }
556166
protected static function _setDbConnectionConfig(array $config)
	{
		$app = \Slim\Slim::getInstance();
		$cfg = Config::instance();
		$cfg->set_connections($config);
		$cfg->set_default_connection($app->config('mode'));
	}
628638
public function set_config(array $config)
    {
        if (isset($config['convert_integers'])) {
            $this->config['convert_integers'] = (bool)$config['convert_integers'];
        }

        if (isset($config['typecast_objects'])) {
            $this->config['typecast_objects'] = (bool)$config['typecast_objects'];
        }

        return $this;
    }
945210
public function setConfig(array $config)
    {
        foreach ($config as $key => $value) {
            $this->_config[$key] = $value;
        }

        return $this;
    }
233617
public function setConfigs($config)
    {
        if (is_array($config) === false && $config instanceof \Traversable === false) {
            throw new \InvalidArgumentException(
                'Expected an array or Traversable; received: ' .
                (is_object($config) === true ? get_class($config) : gettype($config))
            );
        }
        foreach ($config as $name => $value) {
            $this->setConfig($name, $value);
        }
        return $this;
    }
921684
public static function setConfig($config)
	{
		//set the error file path
		self::$errorFilePath = dirname(dirname(__FILE__)) . '/Exceptions/';

		//set the config array
		self::$config = $config; 

	}