/** * Loads client data for a specified client name. * * The client name must exist. You should check whether the client name exists with * the {@link hasClient()} function * * @param string $client the name of the client to load * @return User data for the specified user */ protected function readClient($cid) { if (!$this->isValidName($cid) || !$this->hasClient($cid)) { return null; } $store_file = $this->config['store_dir'] . "/{$cid}.client"; if (file_exists($store_file)) { $client = $this->f3->mutex($store_file, function ($f3, $store_file) { return $f3->unserialize(file_get_contents($store_file)); }, array($this->f3, $store_file)); } else { $client = new Client(); } $client_file = $this->config['identities_dir'] . "/{$cid}.client.yml"; if (file_exists($client_file)) { try { $data = Spyc::YAMLLoad($client_file); } catch (Exception $e) { $this->f3->get('logger')->log(\Psr\Log\LogLevel::ERROR, 'Cannot read client file ' . $client_file . ' :' . $e->getMessage()); trigger_error('Cannot read client file ' . $client_file . ' :' . $e->getMessage(), E_USER_ERROR); } if ($data != null) { $client->loadData($data); } } $client->cid = $cid; return $client; }