本文整理汇总了PHP中Server::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP Server::setName方法的具体用法?PHP Server::setName怎么用?PHP Server::setName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Server
的用法示例。
在下文中一共展示了Server::setName方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: ServerPulse
function ServerPulse()
{
$server = new Server();
//Get server address
$server->setAddress($_SERVER['REMOTE_ADDR']);
//Grab input
$server->setPort($_REQUEST["port"]);
$server->setName($_REQUEST["name"]);
$server->setVersion($_REQUEST["version"]);
$server->setPrivateKey($_REQUEST["fingerprint"]);
$server->setMaxClients($_REQUEST["max"]);
$server->setPublic($_REQUEST["public"]);
$server->setPasswordProtected($_REQUEST["passwordProtected"]);
$server->setAllowGuests($_REQUEST["allowGuests"]);
$server->setUserCount($_REQUEST["users"]);
$server->setUserList($_REQUEST["players"]);
$server->setMotd($_REQUEST["motd"]);
$server->setGameMode($_REQUEST["gamemode"]);
//Update (or create) server record
return Server::updateServer($server);
}
示例2: getServerGroups
function getServerGroups()
{
$sql = "SELECT server_group_id, group_name, description FROM gban_server_group ORDER BY group_name ASC";
$this->db->sql_query($sql);
$groups = $this->db->get_array();
$serverGroups = array();
for ($i = 0; $i < count($groups); $i++) {
$serverGroup = new ServerGroup();
$serverGroup->setId($groups[$i]['server_group_id']);
$serverGroup->setName(stripslashes($groups[$i]['group_name']));
$serverGroup->setDescription(stripslashes($groups[$i]['description']));
// Determine the servers associated with this server group
if ($serverGroup->getId() != null) {
$serversQuery = "SELECT server_id, name, ip, port, type, plugin\r\n FROM gban_servers\r\n WHERE server_group_id = '" . $serverGroup->getId() . "'\r\n ORDER BY server_id";
$this->db->sql_query($serversQuery);
$servers = $this->db->get_array();
$serverList = array();
for ($j = 0; $j < count($servers); $j++) {
$server = new Server();
$server->setId($servers[$j]['server_id']);
$server->setName(stripslashes($servers[$j]['name']));
$server->setIp($servers[$j]['ip']);
$server->setPort($servers[$j]['port']);
$server->setType($servers[$j]['type']);
$server->setPlugin($servers[$j]['plugin']);
array_push($serverList, $server);
// Add the server object to the array
}
$serverGroup->setServers($serverList);
}
// Done getting servers associated with this server group
array_push($serverGroups, $serverGroup);
// Add the server object to the array
}
return $serverGroups;
}
示例3: readSessions
/**
* @see \Simresults\Data_Reader::readSessions()
*/
protected function readSessions()
{
// Get array data
$data = $this->array_data;
// Init sessions array
$sessions = array();
// Loop each session from data
foreach ($data as $session_data) {
// Remember which vehicles are parsed
$vehicle_names = array();
// Init session
$session = Session::createInstance();
// Set session type
$type = null;
switch ($session_data['type']) {
case 'qualify':
$type = Session::TYPE_QUALIFY;
break;
case 'practice':
$type = Session::TYPE_PRACTICE;
break;
case 'warmup':
$type = Session::TYPE_PRACTICE;
break;
case 'race':
$type = Session::TYPE_RACE;
break;
}
$session->setType($type);
// Set session name
if (isset($session_data['name'])) {
$session->setName($session_data['name']);
}
// Set max time
if (isset($session_data['time'])) {
$session->setMaxMinutes($session_data['time']);
}
// Set max laps
if (isset($session_data['laps'])) {
$session->setMaxLaps($session_data['laps']);
}
// Set game
$game = new Game();
$game->setName('Assetto Corsa');
$session->setGame($game);
// Has track
if (isset($session_data['track'])) {
$track = new Track();
$track->setVenue($session_data['track']);
$session->setTrack($track);
}
// Has date
if (isset($session_data['date'])) {
// Set it
$session->setDateString($session_data['date']);
}
// Set server
$server = new Server();
$server->setDedicated(true);
if (isset($session_data['server'])) {
$server->setName($session_data['server']);
} else {
$server->setName('Unknown');
}
$session->setServer($server);
// Add allowed vehicles
foreach ($session_data['car_list'] as $vehicle_name) {
$vehicle = new Vehicle();
$vehicle->setName($vehicle_name);
$session->addAllowedVehicle($vehicle);
}
// Set chats
foreach ($session_data['chats'] as $chat_message) {
$chat = new Chat();
$chat->setMessage($chat_message);
$session->addChat($chat);
}
// Set participants
$participants = array();
foreach ($session_data['participants'] as $part_data) {
// No name
if (!Helper::arrayGet($part_data, 'name')) {
continue;
}
// Create driver
$driver = new Driver();
$driver->setName($part_data['name']);
// Total time not greater than 0
if (0 >= ($total_time = Helper::arrayGet($part_data, 'total_time'))) {
// Total time is null
$total_time = null;
}
// Create participant and add driver
$participant = Participant::createInstance();
$participant->setDrivers(array($driver))->setTotalTime($total_time);
// Has total time parsed data and should not be a forced DNF
if ($total_time and !Helper::arrayGet($part_data, 'force_dnf')) {
//.........这里部分代码省略.........
示例4: readSessions
/**
* @see \Simresults\Data_Reader::readSessions()
*/
protected function readSessions()
{
// Get data
$data = json_decode($this->data, TRUE);
// Get date
preg_match('/\\d{10}/i', $data['Time'], $time_matches);
$date = new \DateTime();
$date->setTimestamp($time_matches[0]);
$date->setTimezone(new \DateTimeZone(self::$default_timezone));
// Get other settings
$other_settings = array();
$known_setting_keys = array('Experience', 'Difficulty', 'FuelUsage', 'MechanicalDamage', 'FlagRules', 'CutRules', 'RaceSeriesFormat', 'WreckerPrevention', 'MandatoryPitstop', 'MandatoryPitstop');
foreach ($known_setting_keys as $setting) {
if ($setting_value = Helper::arrayGet($data, $setting)) {
$other_settings[$setting] = $setting_value;
}
}
// Init sessions array
$sessions = array();
// Gather all sessions
foreach ($data['Sessions'] as $session_data) {
// Init session
$session = Session::createInstance();
// Practice session by default
$type = Session::TYPE_PRACTICE;
// Check session type
switch (strtolower($name = $session_data['Type'])) {
case 'qualify':
$type = Session::TYPE_QUALIFY;
break;
case 'warmup':
$type = Session::TYPE_WARMUP;
break;
case 'race':
$type = Session::TYPE_RACE;
break;
}
// Set session values
$session->setType($type)->setDate($date)->setOtherSettings($other_settings);
// Set game
$game = new Game();
$game->setName('RaceRoom Racing Experience');
$session->setGame($game);
// Set server
$server = new Server();
$server->setName(Helper::arrayGet($data, 'Server'));
$session->setServer($server);
// Set track
$track = new Track();
$track->setVenue(Helper::arrayGet($data, 'Track'));
$session->setTrack($track);
// Get participants and their best lap (only lap)
$participants = array();
$players_data = Helper::arrayGet($session_data, 'Players', array());
foreach ($players_data as $player_index => $player_data) {
// Create driver
$driver = new Driver();
// Has name
if ($name = Helper::arrayGet($player_data, 'Username') or $name = Helper::arrayGet($player_data, 'FullName')) {
$driver->setName($name);
} else {
$driver->setName('unknown');
}
// Create participant and add driver
$participant = Participant::createInstance();
$participant->setDrivers(array($driver))->setPosition(Helper::arrayGet($player_data, 'Position', null));
// Has finish status
if ($status = Helper::arrayGet($player_data, 'FinishStatus')) {
// Figure out status
switch (strtolower($status)) {
case 'finished':
$participant->setFinishStatus(Participant::FINISH_NORMAL);
break;
case 'disqualified':
$participant->setFinishStatus(Participant::FINISH_DQ);
break;
default:
$participant->setFinishStatus(Participant::FINISH_DNF);
break;
}
} else {
$participant->setFinishStatus(Participant::FINISH_NORMAL);
}
// Has total time
if ($total_time = Helper::arrayGet($player_data, 'TotalTime')) {
$participant->setTotalTime(round($player_data['TotalTime'] / 1000, 4));
}
// Create vehicle and add to participant
$vehicle = new Vehicle();
$vehicle->setName(Helper::arrayGet($player_data, 'Car'));
$participant->setVehicle($vehicle);
// Has laps
if ($laps = Helper::arrayGet($player_data, 'RaceSessionLaps')) {
foreach ($laps as $lap_key => $lap_data) {
// Negative lap time, skip
if ($lap_data['Time'] < 0) {
continue;
//.........这里部分代码省略.........
示例5: readSessions
/**
* @see \Simresults\Data_Reader::readSessions()
*/
protected function readSessions()
{
// Get data
$data = json_decode($this->data, TRUE);
// Init session
$session = Session::createInstance();
// Practice session by default
$type = Session::TYPE_PRACTICE;
// Check session name to get type
// TODO: Could we prevent duplicate code for this with other readers?
switch (strtolower($name = Helper::arrayGet($data, 'Type'))) {
case 'qualify session':
case 'qualify':
$type = Session::TYPE_QUALIFY;
break;
case 'warmup session':
$type = Session::TYPE_WARMUP;
break;
case 'race session':
case 'quick race':
case 'race':
$type = Session::TYPE_RACE;
break;
}
// Set session values
$session->setType($type)->setName($name)->setMaxLaps((int) Helper::arrayGet($data, 'RaceLaps'));
// Has Duration
if ($seconds = (int) Helper::arrayGet($data, 'DurationSecs')) {
$session->setMaxMinutes(round($seconds / 60));
} else {
$session->setMaxMinutes(0);
}
// Set game
$game = new Game();
$game->setName('Assetto Corsa');
$session->setGame($game);
// Set server (we do not know...)
$server = new Server();
$server->setName('Unknown');
$session->setServer($server);
// Set track
$track = new Track();
$track->setVenue(Helper::arrayGet($data, 'TrackName'));
$session->setTrack($track);
// Get participants from Cars data
$participants_by_name = array();
$players_data = Helper::arrayGet($data, 'Cars', array());
foreach ($players_data as $player_index => $player_data) {
// Build participant
$participant = $this->getParticipant($name = $player_data['Driver']['Name'], $player_data['Driver']['Guid'], $player_data['Model'], $player_data['Driver']['Team'], $player_data['BallastKG'], $player_data['Skin']);
// Add participant to collection
$participants_by_name[$name] = $participant;
}
// Get participants from result data.
// WARNING: This should be orded by position but these logs are BUGGED.
// DO NOT TRUST!
$players_data = Helper::arrayGet($data, 'Result', array());
foreach ($players_data as $player_index => $player_data) {
// No participant found
if (!isset($participants_by_name[$player_data['DriverName']])) {
// Build participant
$participant = $this->getParticipant($name = $player_data['DriverName'], $player_data['DriverGuid'], $player_data['CarModel'], null, $player_data['BallastKG']);
// Add participant to collection
$participants_by_name[$name] = $participant;
}
$participant = $participants_by_name[$player_data['DriverName']];
// Total time available
if ($total_time = $player_data['TotalTime']) {
$participant->setTotalTime(round($total_time / 1000, 4));
} else {
// DNF
$participant->setFinishStatus(Participant::FINISH_DNF);
}
// Set total time and position (but we can't trust, so we will
// fix later again)
$participant->setPosition($player_index + 1);
}
// Process laps
foreach ($data['Laps'] as $lap_data) {
// Init new lap
$lap = new Lap();
// No participant found
if (!isset($participants_by_name[$lap_data['DriverName']])) {
// Build participant
$participant = $this->getParticipant($name = $lap_data['DriverName'], $lap_data['DriverGuid'], $lap_data['CarModel'], null, $lap_data['BallastKG']);
// Add participant to collection
$participants_by_name[$name] = $participant;
}
$lap_participant = $participants_by_name[$lap_data['DriverName']];
// Set participant
$lap->setParticipant($lap_participant);
// Set first driver of participant as lap driver. AC does
// not support swapping
$lap->setDriver($lap_participant->getDriver());
// Set lap time in seconds
if ($lap_data['LapTime'] !== 99999) {
$lap->setTime(round($lap_data['LapTime'] / 1000, 4));
//.........这里部分代码省略.........
示例6: readSessions
/**
* @see \Simresults\Data_Reader::readSessions()
*/
protected function readSessions()
{
// Get data
$data = json_decode($this->data, TRUE);
// No session data
if (!($sessions_data = Helper::arrayGet($data, 'sessions'))) {
// Throw exception
throw new Exception\Reader('Cannot read the session data');
}
// Init sessions array
$sessions = array();
// Get extra data for all sessions
$extras = array();
foreach (Helper::arrayGet($data, 'extras', array()) as $extras_data) {
// Get name
$name = Helper::arrayGet($extras_data, 'name');
// Loop all values and add as extra settings
foreach ($extras_data as $extra_data_key => $extra_data_value) {
// Is name
if ($extra_data_key === 'name') {
// Skip this
continue;
}
// Add to extras collection
$extras[ucfirst($name) . ' ' . $extra_data_key] = $extra_data_value;
}
}
// Gather all sessions
foreach ($sessions_data as $session_data) {
// Init session
$session = Session::createInstance();
// Get participants (do for each session to prevent re-used objects
// between sessions)
$participants = array();
$players_data = Helper::arrayGet($data, 'players', array());
foreach ($players_data as $player_index => $player_data) {
// Create driver
$driver = new Driver();
$driver->setName(Helper::arrayGet($player_data, 'name'));
// Create participant and add driver
$participant = Participant::createInstance();
$participant->setDrivers(array($driver))->setFinishStatus(Participant::FINISH_NORMAL);
// Create vehicle and add to participant
$vehicle = new Vehicle();
$vehicle->setName(Helper::arrayGet($player_data, 'car'));
$participant->setVehicle($vehicle);
// Add participant to collection
$participants[] = $participant;
}
// Practice session by default
$type = Session::TYPE_PRACTICE;
// Check session name to get type
// TODO: Should be checked when full game is released. Also create
// tests for it!
switch (strtolower($name = Helper::arrayGet($session_data, 'name'))) {
case 'qualify session':
case 'qualify':
$type = Session::TYPE_QUALIFY;
break;
case 'warmup session':
$type = Session::TYPE_WARMUP;
break;
case 'race session':
case 'quick race':
case 'race':
$type = Session::TYPE_RACE;
break;
}
// Set session values
$session->setType($type)->setName($name)->setMaxLaps((int) Helper::arrayGet($session_data, 'lapsCount'))->setMaxMinutes((int) Helper::arrayGet($session_data, 'duration'));
// Set game
$game = new Game();
$game->setName('Assetto Corsa');
$session->setGame($game);
// Set server (we do not know...)
$server = new Server();
$server->setName('Unknown or offline');
$session->setServer($server);
// Set track
$track = new Track();
$track->setVenue(Helper::arrayGet($data, 'track'));
$session->setTrack($track);
// Get the laps
$laps_data = Helper::arrayGet($session_data, 'laps', array());
// No laps data
if (!$laps_data) {
// Use best laps if possible
$laps_data = Helper::arrayGet($session_data, 'bestLaps', array());
}
// Process laps
foreach ($laps_data as $lap_data) {
// Init new lap
$lap = new Lap();
// Set participant
$lap->setParticipant($lap_participant = $participants[$lap_data['car']]);
// Set first driver of participant as lap driver. AC does
// not support swapping
//.........这里部分代码省略.........
示例7: readSessions
/**
* @see \Simresults\Data_Reader::readSessions()
*/
protected function readSessions()
{
// Get data
$data = json_decode(self::cleanJSON($this->data), TRUE);
$data = $data['stats'];
// No session data
if (!($history_data = $data['history'])) {
// Throw exception
throw new Exception\Reader('Cannot read the session data');
}
// Remove sessions without stages
$history_data = array_filter($history_data, function ($data) {
return (bool) $data['stages'];
});
// Get attribute info of project cars to figure out vehicle names etc
$this->attribute_names = $this->getAttributeNames();
// Init sessions array
$sessions = array();
// Loop each history item
foreach ($history_data as $history) {
/**
* Collect all participants
*/
$initial_participants_by_ref = array();
// Depricated! TODO: Remove
$initial_participants_by_id = array();
// Loop all member entries and create participants
foreach ($history['members'] as $part_ref => $part_data) {
// Get participant
$participant = $this->getParticipant($part_data);
// Add participant to collection
// $initial_participants_by_ref[$part_ref] = $participant;
$initial_participants_by_id[$part_data['participantid']] = $participant;
}
// Get additional info from participants entries
// Disabled due to duplicate refids bugs 2015-12-14
// foreach ($history['participants'] as $part_data)
// {
// // Get previously parsed participant
// $participant = $initial_participants_by_ref[
// $part_data['RefId']];
// // Set whether participant is human
// $participant->getDriver()->setHuman(
// (bool) $part_data['IsPlayer']);
// }
// Get server configuration
$read_settings = array('DamageType', 'FuelUsageType', 'PenaltiesType', 'ServerControlsSetup', 'ServerControlsTrack', 'ServerControlsVehicle', 'ServerControlsVehicleClass', 'TireWearType');
$session_settings = array();
foreach ($history['setup'] as $setup_key => $setup_value) {
if (in_array($setup_key, $read_settings)) {
$session_settings[$setup_key] = $setup_value;
}
}
// Loop all stages data
foreach ($history['stages'] as $type_key => $session_data) {
// Make new unique array of participants to prevent reference
// issues across multiple sessions
$participants_by_ref = array();
$participants_by_id = array();
foreach ($initial_participants_by_ref as $part_key => $part) {
$participants_by_ref[$part_key] = clone $part;
}
foreach ($initial_participants_by_id as $part_key => $part) {
$participants_by_id[$part_key] = clone $part;
}
// Init session
$session = Session::createInstance();
// Practice session by default
$type = Session::TYPE_PRACTICE;
// Setup name for session type
$type_setup_name = ucfirst($type_key);
// Check session name to get type
// TODO: Could we prevent duplicate code for this with other readers?
switch (strtolower(preg_replace('#\\d#', '', $type_key))) {
case 'qualifying':
$type = Session::TYPE_QUALIFY;
$type_setup_name = 'Qualify';
break;
case 'warmup':
$type = Session::TYPE_WARMUP;
break;
case 'race':
$type = Session::TYPE_RACE;
break;
}
// Date of this session
$date = new \DateTime();
$date->setTimestamp($session_data['start_time']);
$date->setTimezone(new \DateTimeZone(self::$default_timezone));
// Set session values
$session->setType($type)->setName($type_key)->setMaxLaps($history['setup'][$type_setup_name . 'Length'])->setDate($date)->setOtherSettings($session_settings);
// Set game
$game = new Game();
$game->setName('Project Cars');
$session->setGame($game);
// Set server
// TODO: Set configurations
//.........这里部分代码省略.........
示例8: getServer
/**
* Get the server
*
* @return Server|null
*/
protected function getServer()
{
// Create new server
$server = new Server();
// Not multiplayer. No server data available
if ($this->dom_value('Setting') !== 'Multiplayer') {
return null;
}
// Set game values
$server->setName($this->dom_value('ServerName'))->setMotd($this->dom_value('MOTD'))->setDedicated((bool) $this->dom_value('Dedicated'));
// Return game
return $server;
}
示例9: dirname
<?php
include dirname(__FILE__) . '/../bootstrap/dbunit.php';
$t = new lime_test(4, new lime_output_color());
$extractor = new afColumnExtractor('Server', array('name', 'alert_interval', 'updated_at', 'location_id', 'server_type_id', 'is_enabled', 'osversion', 'html_is_enabled'));
$location = new Location();
$location->setName('myLocation');
$server = new Server();
$server->setName('localhost');
$server->setOsversion('my <version>');
$server->setAlertInterval(300);
$date = '2010-02-14 03:25:45';
$server->setUpdatedAt($date);
$server->setLocation($location);
$server->setIsEnabled(true);
$objects = array($server);
$rows = $extractor->extractColumns($objects);
$row = $rows[0];
$t->like($row['is_enabled'], '@^<img src=\'/images/famfamfam/accept.png\' .*@');
$t->is($row['html_is_enabled'], $row['is_enabled']);
unset($row['is_enabled']);
unset($row['html_is_enabled']);
$expected = array('name' => 'localhost', 'alert_interval' => 300, 'updated_at' => $date, 'location_id' => 'myLocation', 'server_type_id' => null, 'osversion' => 'my <version>');
$t->is($row, $expected);
$t->is(json_encode($row), json_encode($expected));
示例10: getServerList
public static function getServerList()
{
//Grab connection object
$mysqli = Utility::getSQLConnection();
$sql = "SELECT server_id, address, port, version, name, private_key, key_hash, ";
$sql .= "max_clients, public, password_protected, allow_guests, user_count, ";
$sql .= "user_list, motd, game_mode, last_heartbeat_date, created_date ";
$sql .= "FROM servers ";
$sql .= "WHERE last_heartbeat_date > (NOW() - INTERVAL 8 HOUR) ";
$sql .= "ORDER BY last_heartbeat_date DESC";
//Prepare query to find server
$stmt = $mysqli->prepare($sql);
if ($mysqli->errno) {
trigger_error($mysqli->error, E_USER_ERROR);
}
//Run query
$stmt->execute();
if ($mysqli->errno) {
$stmt->close();
unset($stmt);
trigger_error($mysqli->error, E_USER_ERROR);
}
$stmt->bind_result($serverId, $address, $port, $version, $name, $privateKey, $keyHash, $maxClients, $public, $passwordProtected, $allowGuests, $userCount, $userList, $motd, $gameMode, $lastHeartbeatDate, $createdDate);
$serverList = array();
while ($stmt->fetch()) {
$server = new Server();
//Fill server object
$server->setServerId($serverId);
$server->setAddress($address);
$server->setPort($port);
$server->setVersion($version);
$server->setName($name);
$server->setPrivateKey($privateKey);
$server->setPublicKey($keyHash);
$server->setMaxClients($maxClients);
$server->setPublic($public);
$server->setPasswordProtected($passwordProtected);
$server->setAllowGuests($allowGuests);
$server->setUserCount($userCount);
$server->setUserList($userList);
$server->setMotd($motd);
$server->setGameMode($gameMode);
$server->setLastHeartbeatDate($lastHeartbeatDate);
$server->setCreatedDate($createdDate);
$serverList[] = $server;
}
$stmt->close();
unset($stmt);
return $serverList;
}
示例11: getSessions
/**
* @see \Simresults\Data_Reader::getSessions()
*/
public function getSessions()
{
// Get array data
$data = $this->array_data;
// Init sessions array
$sessions = array();
// Remember last qualify session to make up grid positions
$last_qualify_session = null;
// Loop each session from data
foreach ($data as $session_data) {
// Remember which vehicles are parsed
$vehicle_names = array();
// Init session
$session = new Session();
// Set session type
$type = null;
switch ($session_data['type']) {
case 'qualify':
$type = Session::TYPE_QUALIFY;
break;
case 'practice':
$type = Session::TYPE_PRACTICE;
break;
case 'warmup':
$type = Session::TYPE_PRACTICE;
break;
case 'race':
$type = Session::TYPE_RACE;
break;
}
$session->setType($type);
// Set session name
if (isset($session_data['name'])) {
$session->setName($session_data['name']);
}
// Set max time
if (isset($session_data['time'])) {
$session->setMaxMinutes($session_data['time']);
}
// Set max laps
if (isset($session_data['laps'])) {
$session->setMaxLaps($session_data['laps']);
}
// Set game
$game = new Game();
$game->setName('Assetto Corsa');
$session->setGame($game);
// Has track
if (isset($session_data['track'])) {
$track = new Track();
$track->setVenue($session_data['track']);
$session->setTrack($track);
}
// Has date
if (isset($session_data['date'])) {
// Set it
$session->setDateString($session_data['date']);
}
// Set server
$server = new Server();
$server->setDedicated(true);
if (isset($session_data['server'])) {
$server->setName($session_data['server']);
} else {
$server->setName('Unknown');
}
$session->setServer($server);
// Add allowed vehicles
foreach ($session_data['car_list'] as $vehicle_name) {
$vehicle = new Vehicle();
$vehicle->setName($vehicle_name);
$session->addAllowedVehicle($vehicle);
}
// Set chats
foreach ($session_data['chats'] as $chat_message) {
$chat = new Chat();
$chat->setMessage($chat_message);
$session->addChat($chat);
}
// Set participants
$participants = array();
foreach ($session_data['participants'] as $part_data) {
// No name
if (!Helper::arrayGet($part_data, 'name')) {
continue;
}
// Create driver
$driver = new Driver();
$driver->setName($part_data['name']);
// Total time not greater than 0
if (0 >= ($total_time = Helper::arrayGet($part_data, 'total_time'))) {
// Total time is null
$total_time = null;
}
// Create participant and add driver
$participant = new Participant();
$participant->setDrivers(array($driver))->setTotalTime($total_time);
//.........这里部分代码省略.........