Set an item for current request in default config if custom is null, else in custom config.

@return void
345169
protected function setConfig($item, $value)
	{
		// Set config item value for a custom layout if it exists
		if (!is_null(Config::get($this->configNamePrefix.$this->layout.'.'.$item)))
		{
			return Config::set($this->configNamePrefix.$this->layout.'.'.$item, $value);
		}

		// Set default config item value if custom one does exist
		else
		{
			return Config::set($this->configNamePrefix.$item, $value);
		}
	}
1097314
protected function setDefaultOptions() : void
    {
        $this->setDefaultFieldOptions();
        $this->setDefaultFieldDefinitions();
        $this->setDefaultLabel();
        $this->setDefaultValue();
    }
701420
protected function initDefaults()
    {
        if ($this->properties['header'] === null) {
            $this->setHeader($this->name);
        }
        if ($this->properties['type'] === null) {
            $this->setType(ColumnType::createType(ColumnType::TYPE_STRING));
        }
    }
1080326
protected function set_defaults()
	{
		$this->options   = $this->default_options;
		$this->params    = $this->default_params;
		return $this;
	}
1312531
private function _set_params()
    {
        // Get values from request
        $params = \Request::route('params');
        $filepath = $this->config['abs_path'] . '/' . \Request::route('imagepath');
        
        // echo $params; exit;
        
        // If enforcing params, ensure it's a match
        if ($this->config['enforce_presets'] && !in_array($params, $this->config['presets'])) {
            abort(404);
        }
        
        $image = new Image();
        $image->configure(config('image'));
        if (function_exists('exif_read_data')) {
            $this->image = $image->make($filepath)->orientate();
        } else {
            $this->image = $image->make($filepath);
        }
        
        // The parameters are separated by hyphens
        $raw_params = explode('-', $params);
        
        // Update param values from passed values
        foreach ($raw_params as $raw_param) {
            $name = $raw_param[0];
            $value = substr($raw_param, 1, strlen($raw_param) - 1);
            
            if ($name == 'c') {
                $this->url_params[$name] = TRUE;
                
                // When croping, we must have a width and height to pass to imagecreatetruecolor method
                // Make width the height or vice versa if either is not passed
                if (empty($this->url_params['w'])) {
                    $this->url_params['w'] = $this->url_params['h'];
                }
                if (empty($this->url_params['h'])) {
                    $this->url_params['h'] = $this->url_params['w'];
                }
            } elseif (key_exists($name, $this->url_params)) {
                // Remaining expected params (w, h, q)
                $this->url_params[$name] = $value;
            } else {
                // Watermarks or invalid params
                $this->url_params[$raw_param] = $raw_param;
            }
        }
        
        // Do not scale up images
        if (! $this->config['scale_up']) {
            if ($this->url_params['w'] > $this->image->width()) {
                $this->url_params['w'] = $this->image->width();
            }
            if ($this->url_params['h'] > $this->image->height()) {
                $this->url_params['h'] = $this->image->height();
            }
        }
        
        // Must have at least a width or height
        if (empty($this->url_params['w']) and empty($this->url_params['h'])) {
            throw new HTTP_Exception_404('The requested URL :uri was not found on this server.', array(
                ':uri' => Request::$current->uri()
            ));
        }
        
        // Set the url filepath
        $this->source_file = $filepath;
    }
395112
private static function setDefaultConfig() {
            if (!self::$defaults) {
                self::$defaults = [self::CFG_ERROR_LEVEL        => error_reporting(),
                                   self::CFG_LOG_ERROR_LOCATION => true];
            }
        }
61767
protected function setDefaultParams()
    {
        foreach ($this->allowedParams as $param => $options) {
            $this->params[$param] = null;
            if (! empty($options['arguments'])) {
                $this->params[$param] = array();
                foreach ($options['arguments'] as $arg => $opts) {
                    if (! empty($opts['default'])) {
                        $cast = ! empty($opts['cast']) ? $opts['cast'] : 'string';
                        $this->params[$param][$arg] = $this->castValue($cast, $opts['default']);
                    }
                }
            } elseif (! empty($options['default'])) {
                $cast = ! empty($options['cast']) ? $options['cast'] : 'string';
                $this->params[$param] = $this->castValue($cast, $options['default']);
            }
        }
    }
1200981
public function configDefault($key, $default = null)
    {
        $value = $this->config($key);
        if ($value === null) {
            $this->config($key, $default);
        }
    }
527490
protected function setDefaultData()
    {
        $this->data = array_merge($this->data, $this->getDefaultData());

        $this->data['_version'] = gplcart_version();
        $this->data['_user'] = $this->current_user;
        $this->data['_store'] = $this->current_store;
        $this->data['_language'] = $this->current_language;
        $this->data['_maintenance'] = $this->is_maintenance;
        $this->data['_messages'] = $this->session->getMessage();

        $default_langcode = $this->language->getDefault();

        foreach ($this->language->getList() as $code => $language) {
            if (!empty($language['status']) || $code === $default_langcode) {
                $this->data['_languages'][$code] = $language;
            }
        }

        $this->data['_store_title'] = $this->store->getTranslation('title', $this->langcode);

        if (!empty($this->current_store['data']['logo'])) {
            $this->data['_store_logo'] = $this->image($this->current_store['data']['logo']);
        }

        if (!empty($this->current_store['data']['favicon'])) {
            $this->data['_store_favicon'] = $this->image($this->current_store['data']['favicon']);
        }

        $this->setClasses();
        $this->setDefaultJs();
    }
829670
protected function _setDefaults()
    {
        $defaults = [
            'authenticate' => [
                'Form' => [
                    'finder'    => 'auth',
                    'userModel' => 'Community.Users',
                    'fields'    => [
                        'username' => 'login',
                        'password' => 'password'
                    ],
                ]
            ],
            'flash' => [
                'key'       => 'auth',
                'element'   => 'error',
                'params'    => ['class' => 'error']
            ],
            'loginAction' => [
                'controller' => 'Users',
                'action'     => 'login',
                'plugin'     => 'Community'
            ],
            'unauthorizedRedirect' => [
                'action'     => 'login',
                'controller' => 'Users',
                'plugin'     => 'Community'
            ],
            'authorize'      => ['Community.Base'],
            'loginRedirect'  => $this->_getLoginRedirect(),
            'logoutRedirect' => $this->_config['loginAction'],
            'authError'      => __d('community', 'You are not authorized to access that location.')
        ];

        $config = $this->getConfig();
        foreach ($config as $key => $value) {
            if ($value !== null) {
                unset($defaults[$key]);
            }
        }

        $this->setConfig($defaults);
    }
983787
private function setDefaultValues()
    {
        // Set default payment action.
        if (empty($this->paymentAction)) {
            $this->paymentAction = 'Sale';
        }

        // Set default locale.
        if (empty($this->locale)) {
            $this->locale = 'en_US';
        }

        // Set default value for SSL validation.
        if (empty($this->validateSSL)) {
            $this->validateSSL = false;
        }
    }
145855
protected function set_defaults()
	{
		parent::set_defaults();
		$this->headers = array();

		if ( ! empty($this->preserve_resource))
		{
			$this->resource = $this->preserve_resource;
			$this->preserve_resource = null;
		}

		return $this;
	}
892114
public function init()
    {
        $grav = Grav::instance();

        /** @var Config $config */
        $config = $grav['config'];

        /** @var Language $language */
        $language = $grav['language'];

        // add the port to the base for non-standard ports
        if ($this->port !== null && $config->get('system.reverse_proxy_setup') === false) {
            $this->base .= ':' . (string)$this->port;
        }

        // Handle custom base
        $custom_base = rtrim($grav['config']->get('system.custom_base_url'), '/');

        if ($custom_base) {
            $custom_parts = parse_url($custom_base);
            $orig_root_path = $this->root_path;
            $this->root_path = isset($custom_parts['path']) ? rtrim($custom_parts['path'], '/') : '';
            if (isset($custom_parts['scheme'])) {
                $this->base = $custom_parts['scheme'] . '://' . $custom_parts['host'];
                $this->root = $custom_base;
            } else {
                $this->root = $this->base . $this->root_path;
            }
            $this->uri = Utils::replaceFirstOccurrence($orig_root_path, $this->root_path, $this->uri);
        } else {
            $this->root = $this->base . $this->root_path;
        }

        $this->url = $this->base . $this->uri;

        $uri = str_replace(static::filterPath($this->root), '', $this->url);

        // remove the setup.php based base if set:
        $setup_base = $grav['pages']->base();
        if ($setup_base) {
            $uri = preg_replace('|^' . preg_quote($setup_base, '|') . '|', '', $uri);
        }

        // process params
        $uri = $this->processParams($uri, $config->get('system.param_sep'));

        // set active language
        $uri = $language->setActiveFromUri($uri);

        // split the URL and params
        $bits = parse_url($uri);

        //process fragment
        if (isset($bits['fragment'])) {
            $this->fragment = $bits['fragment'];
        }

        // Get the path. If there's no path, make sure pathinfo() still returns dirname variable
        $path = $bits['path'] ?? '/';

        // remove the extension if there is one set
        $parts = pathinfo($path);

        // set the original basename
        $this->basename = $parts['basename'];

        // set the extension
        if (isset($parts['extension'])) {
            $this->extension = $parts['extension'];
        }

        // Strip the file extension for valid page types
        if ($this->isValidExtension($this->extension)) {
            $path = Utils::replaceLastOccurrence(".{$this->extension}", '', $path);
        }

        // set the new url
        $this->url = $this->root . $path;
        $this->path = static::cleanPath($path);
        $this->content_path = trim(str_replace($this->base, '', $this->path), '/');
        if ($this->content_path !== '') {
            $this->paths = explode('/', $this->content_path);
        }

        // Set some Grav stuff
        $grav['base_url_absolute'] = $config->get('system.custom_base_url') ?: $this->rootUrl(true);
        $grav['base_url_relative'] = $this->rootUrl(false);
        $grav['base_url'] = $config->get('system.absolute_urls') ? $grav['base_url_absolute'] : $grav['base_url_relative'];

        RouteFactory::setRoot($this->root_path);
        RouteFactory::setLanguage($language->getLanguageURLPrefix());
    }
1301817
protected function _default()
    {
        $this->url           = NULL;
        $this->data          = NULL;
        $this->sslVerifyPeer = false;
    }
867224
private function setMissingDefaults()
    {
        if (!isset($this->data['contenttype_groups'])) {
            $this->data['contenttype_groups'] = array('Content');
        }

        if ($this->notSetOrEmpty($this->data, 'names')) {
            $this->data['names'] = array(
                $this->data['main_language_code'] => $this->identifierToReadable($this->data['identifier']),
            );
        }

        foreach (array('name_schema', 'url_alias_schema') as $schema) {
            if ($this->notSetOrEmpty($this->data, $schema)) {
                $this->data[$schema] = sprintf('<%s>', $this->data['fields'][key($this->data['fields'])]->data['identifier']);
            }
        }
    }
680127
public function initialize()
    {
        if (is_null($value = $this->getValue())) {
            $value = request()->input($this->getAlias());
        }

        $this->setValue($value);
    }
1070334
public function setDefaultAction()
    {
        $params     = $this->params();
        $locator    = $this->getServiceLocator();
        $model      = $locator->get( 'Grid\User\Model\User\Group\Model' );
        $group      = $model->find( $params->fromRoute( 'id' ) );

        if ( empty( $group ) )
        {
            $this->getResponse()
                 ->setStatusCode( 404 );

            return;
        }

        if ( $group->predefined )
        {
            $this->getResponse()
                 ->setStatusCode( 403 );

            return;
        }

        if ( ! $this->getPermissionsModel()
                    ->isAllowed( $group, 'edit' ) )
        {
            $this->getResponse()
                 ->setStatusCode( 403 );

            return;
        }

        if ( ! $group->default )
        {
            $group->default = true;

            if ( $group->save() )
            {
                $this->messenger()
                     ->add( 'user.form.group.success',
                            'user', Message::LEVEL_INFO );
            }
            else
            {
                $this->messenger()
                     ->add( 'user.form.group.failed',
                            'user', Message::LEVEL_ERROR );
            }
        }

        return $this->redirect()
                    ->toRoute( 'Grid\User\GroupAdmin\List', array(
                        'locale' => (string) $this->locale(),
                    ) );
    }