yii\elasticsearch\Connection::init PHP Method

init() public method

public init ( )
    public function init()
    {
        foreach ($this->nodes as &$node) {
            if (!isset($node['http_address'])) {
                throw new InvalidConfigException('Elasticsearch node needs at least a http_address configured.');
            }
            if (!isset($node['protocol'])) {
                $node['protocol'] = $this->defaultProtocol;
            }
            if (!in_array($node['protocol'], ['http', 'https'])) {
                throw new InvalidConfigException('Valid node protocol settings are "http" and "https".');
            }
        }
    }

Usage Example

 public function init()
 {
     parent::init();
     if (is_null($this->index)) {
         throw new InvalidParamException('Property "index" must be set');
     }
 }