Creates a new user and returns its configuration (with the new ID)

@param array $cfg A configuration array
@return array|false
188483
public function add($cfg)
	{
	  $u =& $this->class_cfg['arch']['users'];
    $fields = array_unique(array_values($u));
    $cfg[$u['active']] = 1;
    $cfg[$u['cfg']] = '{}';
    foreach ( $cfg as $k => $v ){
      if ( !\in_array($k, $fields) ){
        unset($cfg[$k]);
      }
    }
    if ( isset($cfg['id']) ){
      unset($cfg['id']);
    }
    if (
      bbn\str::is_email($cfg[$u['email']]) &&
            $this->db->insert($this->class_cfg['tables']['users'], $cfg)
    ){
      $cfg[$u['id']] = $this->db->last_id();

      // Envoi d'un lien
      $this->make_hotlink($cfg[$this->class_cfg['arch']['users']['id']], 'creation');
      return $cfg;
    }
		return false;
	}
314558
public static function getInstance(array $config)
    {
        if (empty($config)) {
            throw new \Exception('i18n configuration can not be empty.');
        }
        if (self::$i18n === null) {
            self::$i18n = new self($config);
        }

        return self::$i18n;
    }
1023039
public function add(array $cfg): ?string
  {
    if (
      $this->id_user &&
      (null !== $cfg['request']) &&
      $this->check()
    ){
      $t = new bbn\util\timer();
      $t->start();
      if ( is_string($cfg['request']) ){
        $params = self::sanitize_params($cfg['params'] ?? []);
        $request = trim($cfg['request']);
      }
      else if ( is_array($cfg['request']) ){
        $params = null;
        $request = $cfg['request'];
      }
      else{
        return null;
      }
      $res = $this->_exec($request, $params);
      $duration = (int)ceil($t->stop() * 1000);
      if ( is_array($request) ){
        $request = json_encode($request);
      }
      $id_alias = $this->_get_id($request, $params);
      //die(var_dump($id_alias, $this->db->last()));
      // If it is a public observer it will be the id_alias and the main observer
      if (
        !$id_alias &&
        !empty($cfg['public']) &&
        $this->db->insert('bbn_observers', [
          'request' => $request,
          'params' => $params ?: null,
          'name' => $cfg['name'] ?? null,
          'duration' => $duration,
          'id_user' => null,
          'public' => 1,
          'result' => $res
        ])
      ){
        $id_alias = $this->db->last_id();
      }
      // Getting the ID of the observer corresponding to current user
      if ( $id_obs = $this->_get_id_from_user($request, $params) ){
        //
        $this->check_result($id_obs);
        return $id_obs;
      }
      else if ( $id_alias ){
        if ( $this->db->insert('bbn_observers', [
          'id_user' => $this->id_user,
          'public' => 0,
          'id_alias' => $id_alias,
          'next' => null,
          'result' => $res
        ]) ){
          return $this->db->last_id();
        }
      }
      else{
        if ( $this->db->insert('bbn_observers', [
          'request' => $request,
          'params' => $params ?: null,
          'name' => $cfg['name'] ?? null,
          'duration' => $duration,
          'id_user' => $this->id_user,
          'public' => 0,
          'result' => $res
        ]) ){
          return $this->db->last_id();
        }
      }
    }
    return null;
  }
166839
static public function config($config = array())
    {
        !empty($config) && self::$config = array_merge(self::$config, $config);
        if (!empty(self::$config['cachepath'])) {
            Cache::$cachepath = self::$config['cachepath'];
        }
        if (empty(self::$config['component_verify_ticket'])) {
            self::$config['component_verify_ticket'] = Cache::get('component_verify_ticket');
        }
        if (empty(self::$config['token']) && !empty(self::$config['component_token'])) {
            self::$config['token'] = self::$config['component_token'];
        }
        if (empty(self::$config['appsecret']) && !empty(self::$config['component_appsecret'])) {
            self::$config['appsecret'] = self::$config['component_appsecret'];
        }
        if (empty(self::$config['encodingaeskey']) && !empty(self::$config['component_encodingaeskey'])) {
            self::$config['encodingaeskey'] = self::$config['component_encodingaeskey'];
        }
        return self::$config;
    }
954696
public function create($config){

        $creator = $this->getCreator($config);

        return $this->callCreator($creator, $config);

    }
1211776
public function create(array $config = [])
    {
        if (null === $this->handler) {
            $this->handler = DefaultHandler::create();
        }

        return new Client(
            array_merge_recursive(
                [
                    'verify'  => false,
                    'handler' => $this->handler,
                ],
                $config
            )
        );
    }
705792
public function update(string $id, array $cfg): int
  {
    return $this->db->update($this->class_cfg['table'], [
      $this->fields['text'] => $cfg[$this->fields['text']] ?? NULL,
      $this->fields['num'] => $cfg[$this->fields['num']] ?? NULL,
      $this->fields['id_link'] => $cfg[$this->fields['id_link']] ?? NULL,
      $this->fields['id_alias'] => $cfg[$this->fields['id_alias']] ?? NULL,
      $this->fields['id_user'] => $this->id_user,
      $this->fields['cfg'] => ($mp = $this->get_cfg(false, $cfg)) ? json_encode($tmp) : NULL
    ], [
      $this->fields['id'] => $id
    ]);
  }
480949
protected function createUsersBroker(array $config)
    {
        return new VerificationBroker(
            $this->createTokenRepository($this->app['config']['verification.repositories.'.$config['repository']]),
            $this->app['auth']->createUserProvider($config['provider']),
            $this->app['mailer'],
            $config['email']
        );
    }
788592
public function create(array $config)
    {
        $dashboard = new Dashboard();

        foreach ($config as $name => $cfg) {
            $widget = $this->widgetFactory->create($name, $cfg['type'], $cfg['options']);
            $dashboard->addWidget($widget);
        }

        return $dashboard;
    }
1094569
public static function getInstance(Configuration $cfg) {
        $cache = null;
        if (extension_loaded('redis')) {
            $redisConfig = $cfg->get('redis');
            if ($redisConfig) {
                list($host, $port, $db, $timeout, $auth) = $redisConfig;
                $redis = RedisClient::getRedis([$host, $port, $timeout, $auth, $db]);
                if ($redis) {
                    $cache = new RedisCache($redis);
                }
            }
        }

        return $cache;
    }
464831
public function client(array $config)
    {
        $key = $this->getClientKey($config);

        if (isset($this->clients[$key])) {
            return $this->clients[$key];
        }

        return $this->clients[$key] = $this->createClient($config);
    }
1101803
protected function instantiateConfig($config = null)
    {
        if (is_null($this->config) || ! is_null($config)) {
            $this->config = ! is_null($config)
                ? $config
                : new Config($this->helper);
        }

        return $this->config;
    }
1165496
public static function factory($config = array())
    {
        $required = array(
            'base_url',
            'username',
            'password',
        );

        $defaults = array(
            'base_url' => self::BASE_URL,
            'base_path' => self::BASE_PATH,
        );

        // Instantiate the Acquia Search plugin.
        $config = Collection::fromConfig($config, $defaults, $required);
        $client = new static($config->get('base_url'), $config);
        $client->setDefaultHeaders(array(
            'Content-Type' => 'application/json; charset=utf-8',
        ));

        // Attach the Acquia Search plugin to the client.
        $plugin = new CloudApiAuthPlugin($config->get('username'), $config->get('password'));
        $client->addSubscriber($plugin);

        return $client;
    }
976216
public static function bootstrap($cfg = array())
    {
        self::normalizeServerVar();
        $debug = Debug::getInstance();
        $hasLog = $debug->internal->hasLog();
        $collectWas = $debug->setCfg('collect', true);
        self::setCfg($cfg);
        self::checkSettings();
        self::checkRequestVars();
        $debug->setCfg('collect', $collectWas);
        if (!$hasLog) {
            $entryCount = $debug->getData('entryCount');
            $debug->setData('entryCountInitial', $entryCount);
        }
    }
22096
public static function instance($name = 'default', array $config = array())
    {
        if ( ! isset(self::$instances[$name])) {
            if (empty($config)) {
                // Load the configuration for this database
                $config = self::config($name);
            }

            self::$instances[$name] = new self($name, $config);
        }

        return self::$instances[$name];
    }
879361
public function input($cfg=array())
	{
		if ( \is_array($cfg) && isset($cfg['attr']['name']) ){
      
      self::give_id($cfg);
      if ( isset($cfg['field']) ){
        $cfg = bbn\x::merge_arrays(self::specs('fields', $cfg['field']), $cfg);
      }
      
      /*
      if ( !isset($cfg['tag']) ){
        $cfg['tag'] = 'input';
      }
      if ( !isset($cfg['attr']['type']) ){
        $cfg['attr']['type'] = 'text';
      }
      */

      if ( isset($cfg['data']) ){
        if ( isset($cfg['data']['sql'], $this->_current_cfg['data']['db']) ){
          $db =& $this->_current_cfg['data']['db'];
          if ( !isset($cfg['widget']['options']['dataSource']) ){
            $cfg['widget']['options']['dataSource'] = [];
          }
          $count = ( $r = $db->query($cfg['data']['sql']) ) ? $r->count() : 0;
          if ( $count <= self::max_values_at_once ){
            if ( $ds = $db->get_irows($cfg['data']['sql']) ){
              foreach ( $ds as $d ){
                if ( \count($d) > 1 ){
                  array_push($cfg['widget']['options']['dataSource'], [
                      'value' => $d[0],
                      'text' => $d[1]
                  ]);
                }
                else{
                  array_push($cfg['widget']['options']['dataSource'], $d[0]);
                }
              }
            }
          }
          else{
            $cfg['field'] = 'autocomplete';
          }
        }
        else if ( \is_array($cfg['data']) && (\count($cfg['data']) > 0) ){
          if ( isset($cfg['data'][0]) ){
            $cfg['widget']['options']['dataSource'] = $cfg['data'];
          }
          else{
            $cfg['widget']['options']['dataSource'] = [];
            foreach ( $cfg['data'] as $k => $v ){
              array_push($cfg['widget']['options']['dataSource'], [
                  'value' => $k,
                  'text' => $v
              ]);
            }
          }
        }
        if ( isset($cfg['widget']['options']['dataSource'][0]['text']) ){
          $cfg['widget']['options']['dataTextField'] = 'text';
          $cfg['widget']['options']['dataValueField'] = 'value';
        }
			}

      if ( \is_array($cfg) ){
        // Size calculation
        if ( isset($cfg['attr']['maxlength']) && !isset($cfg['attr']['size']) ){
          if ( $cfg['attr']['maxlength'] <= 20 ){
            $cfg['attr']['size'] = (int)$cfg['attr']['maxlength'];
          }
        }
        if ( isset($cfg['attr']['size'], $cfg['attr']['minlength']) && $cfg['attr']['size'] < $cfg['attr']['minlength']){
          $cfg['attr']['size'] = (int)$cfg['attr']['minlength'];
        }
        
        


        $cfg = array_filter($cfg, function($a){
          return !( \is_array($a) && \count($a) === 0 );
        });

      }
      
      if ( isset($cfg['null']) && $cfg['null'] ){
        if ( empty($cfg['attr']['value']) ){
          $cfg['attr']['value'] = null;
          $cfg['attr']['disabled'] = true;
          if ( isset($cfg['widget']) ){
            if ( !isset($cfg['script']) ){
              $cfg['script'] = '';
            }
            /*
            $cfg['script'] .= 'if ( $("#'.$cfg['attr']['id'].'").data("'.$cfg['widget']['name'].'") ){
              $("#'.$cfg['attr']['id'].'").data("'.$cfg['widget']['name'].'").enable(false);
            }
            else if ( $("#'.$cfg['attr']['id'].'").'.$cfg['widget']['name'].' ){
              $("#'.$cfg['attr']['id'].'").'.$cfg['widget']['name'].'("enable", false);
            }';
             * 
             */
          }
        }
      }
      $t = new input($cfg);
      return $t;
		}
		return false;
	}
1051090
public static function getInstance(array $config = [])
        {
            if (!is_object(static::$self)) {
                $className = get_called_class();
                static::$self = new $className($config);
            } else {
                // Add new config settings if given
                if (Arrays::is($config) && count($config) > 0) {
                    static::$self->config($config);
                }
            }

            return static::$self;
        }