initialization

@param array $options
@param array $default
343359
private function init(array $options, array $default = []): void
    {
        $options = array_merge($default, $options);

        //Check if the cookie is valid according to RFC 6265
        if (empty($options['name']) && !is_numeric($options['name'])) {
            throw new InvalidArgumentException('Cookie must have its name!');
        }

        // Check if any of the invalid characters are present in the cookie name
        if (preg_match('/[\x00-\x20\x22\x28-\x29\x2c\x2f\x3a-\x40\x5c\x7b\x7d\x7f]/', $options['name'])) {
            throw new InvalidArgumentException(
                'Cookie name must not contain invalid characters: ASCII '
                . 'Control characters (0-31;127), space, tab and the '
                . 'following characters: ()<>@,;:\"/?={}'
            );
        }

        if (!empty($options['value']) && !isset($options['expires'])) {
            //有值但没有设定过期时间,是会话cookie
            $this->session = true;
            $this->expires = time();
        }

        foreach ($options as $key => $val) {
            //insure value is the correct type
            if (isset($this->$key) && settype($val, gettype($this->$key)) && !empty($key)) {
                $this->$key = $val;
            }
        }

        //tip: (if it's necessary?)
        if (substr($this->path, 0, 1) !== '/') {
            $this->path = '/' . $this->path; // complete the leftmost "/"
        }

        //check is it hostonly
        if (substr($this->domain, 0, 1) === '.') {
            $this->domain = ltrim($this->domain, '.');
            $this->hostonly = false;
        }
    }
828780
protected function childInitialize(array $options = array())
    {
        $this->prepared = false;
        $this->removeAllListeners();
        $this->master = false;
        $pid = posix_getpid();
        $this->ppid = $this->pid;
        $this->pid = $pid;
        $this->queue = null;
        $this->process = new Process($this, $this->pid, $this->ppid);
        $this->children = array();
        $this->prepared = true;

        $options = $options + self::$child_options;

        $this->childProcessOptions($options);
    }
611816
protected function setDefaultOptions(array $options=[])
	{
		if (isset($options['intermediate_model'])) {
			$intermediateModel = $options['intermediate_model'];
		} else {
			$this->text['intermediate_text'] = "[".$this->command->paintString('intermediate model' ,'brown')."]";
			$intermediateModel = $this->manager->getModel(
									$this->command->choice("Choice {$this->text['intermediate_text']} of both relation!",
									$this->manager->getModels()->keys()->toArray())
								 );
		}

		$this->defaultOptions = [
			'intermediate_model' => $intermediateModel,
			'first_key' => $this->model->getForeignKey(),
			'second_key' => $intermediateModel->getForeignKey(),
			'primary_key' => $this->model->getKeyName()
		];
	}
738866
public static function init($settings = null)
	{
		if (!is_null($settings))
			self::$settings = array_replace_recursive(self::$settings, $settings);
	}
1168720
public function setOptions($options = [])
    {
        if (!is_array($options)) {
            $options = [];
        }

        $this->options = array_merge($this->getDefaults(), $options);
        return $this;
    }
1096885
protected function initDefaultConfig(array $options) {
        $configLocation = isset($options['app.dir.config']) ? $options['app.dir.config'] : getcwd();
        $config = new DefaultConfig($configLocation);
        unset($options['app.dir.config']);

        $rootDir = isset($options['app.dir.root']) ? $options['app.dir.root'] : getcwd();
        unset($options['app.dir.root']);

        // copy remaining config options to the DefaultConfig
        foreach ($options as $name => $value) {
            $config->set($name, $value);
        }

        // set root directory and expand relative app directories
        $config->set('app.dir.root', $rootDir);
        $this->expandAppDirs($config, $rootDir);

        return $config;
    }
470764
protected function _initializationOptions($options = array()) {
		$defaults = array(
			'_buffer' => true,
			'_css' => true,
			'_cssText' => true,
			'_scripts' => true,
			'_scriptBlock' => false,
			'_editor' => true,
			'_inline' => true,
		);

		return json_encode(array_diff_key(array_merge(
			$defaults,
			(array)$options
		), $defaults));
	}
568090
public function initialize(array $options)
    {
        $controller = $this->_registry->getController();

        $this->authUser = $controller->Auth->user();
        Configure::write('GlobalAuth', $this->authUser);
    }
148080
function setInitializers($options)
    {
        foreach ($options as $key => $v) {
            if (!(is_array($v) || $v instanceof iContainerInitializer))
                $v = array($key => $v);

            $this->addInitializer($v);
        }

        return $this;
    }
747808
public function init(): void
    {
        parent::init();

        if ($this->default !== '' && $this->default !== null && !is_array($this->default)) {
            try {
                $default = Json::decode($this->default);

                if (is_array($default)) {
                    $this->default = $default;
                }
            } catch (InvalidArgumentException $exception) {}
        }
    }
440498
public function setup(array $options)
    {
        foreach ($options as $method => $value) {
            $method = 'set' . ucfirst($method);
            if (method_exists($this, $method)) {
                $this->{$method}($value);
            }
        }
    }
711409
public function setDefaults(array $defaults)
    {
        foreach ($defaults as $option => $value) {
            $this->setDefault($option, $value);
        }

        return $this;
    }
984123
protected function setDefaultOptions(array $options = [])
    {
        $this->options = $this->formHelper->mergeOptions($this->allDefaults(), $this->getDefaults());
        $this->options = $this->prepareOptions($options);
    }
706636
public function init( $config = [ ] )
    {
        $this->initDefaults();

        $this->initMail( $config );

        $this->initLog( $config );

        $this->initDatabase( $config );

        $this->initRequest( $config );

        $this->initRouter( $config );

        $this->initSession( $config );

        $this->initAppName( $config );

        $this->initDefaultLanguage( $config );

//        $this->_initMaintenanceMode( $config );
    }
952594
protected function initialize(InputInterface $input, OutputInterface $output)
  {
    foreach($input->getArguments() + $input->getOptions() as $arg => $value)
    {
      if(property_exists($this, $arg))
      {
        $this->$arg = $value;
      }
    }
  }
844766
protected function initialize()
    {
        parent::initialize();

        // unless already configured, set default options to include exceptions
        $options = $this->defaults->getOptions() ?: [];

        foreach ($this->soapOptionDefaults as $option => $value) {

            if ( ! array_key_exists($option, $options)) {

                $options[ $option ] = $value;
            }
        }

        $this->defaults->setOptions($options);
    }
546113
public static function start($options) {
		// setting default options
		foreach (self::$default_options as $k => $v) {
			if (isset($options[$k]) || array_key_exists($k, $options)) {
				ini_set("session.$k", $options[$k]);
				self::$default_options[$k] = $options[$k];
			} else if (isset(self::$default_options[$k])) {
				ini_set("session.$k", $v);
			}
		}
		// session # replacement
		$__session_id = \Application::get('flag.global.__session_id');
		if (!empty($__session_id)) {
			session_id($__session_id);
		}
		// starting session submodule if we have one
		$class = Application::get('flag.global.session.submodule', ['class' => 1]);
		// check if backend has been enabled
		if (!\Application::get($class, ['submodule_exists' => true])) {
			Throw new Exception('You must enable ' . $class . ' first!');
		}
		// initialize
		if (!empty($class)) {
			self::$object = new $class();
			self::$object->init();
		}
		// starting session
		session_start();
		// session fixation prevention
		if (empty($_SESSION['numbers']['flag_generated_by_system'])) {
			session_regenerate_id(true);
			$_SESSION = [];
			$_SESSION['numbers']['flag_generated_by_system'] = true;
		}
		// processing IP address
		$ip = \Request::ip();
		// we need to reset ip address details if we have different ip
		if (!empty($_SESSION['numbers']['ip']['ip']) && $_SESSION['numbers']['ip']['ip'] != $ip) {
			$_SESSION['numbers']['ip'] = [];
		}
		// we need to try to decode ip address
		$ip_decoder_submodule = \Application::get('flag.global.ip.submodule');
		if (!empty($ip_decoder_submodule) && !isset($_SESSION['numbers']['ip']['ip'])) {
			$ip_object = new \Object\Miscellaneous\IP();
			$ip_data = $ip_object->get($ip);
			if ($ip_data['success']) {
				$_SESSION['numbers']['ip'] = array_merge2(['ip' => $ip], $ip_data['data']);
			}
		}
		// we only store ip address if its not set
		if (!isset($_SESSION['numbers']['ip']['ip'])) {
			$_SESSION['numbers']['ip'] = [
				'ip' => $ip
			];
		}
		// add anonymous role
		if (!\User::authorized()) {
			\User::roleGrant(\Object\ACL\Resources::getStatic('user_roles', 'anonymous', 'data'));
		}
	}