ILIAS  trunk Revision v11.0_alpha-1862-g4e205cb56d4
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilECSServerSettings Class Reference

Collection of ECS settings. More...

+ Collaboration diagram for ilECSServerSettings:

Public Member Functions

 activeServerExists ()
 Check if there is any active server. More...
 
 serverExists ()
 Check if there is any server. More...
 
 getServers (int $server_type)
 Get servers The function must be called with ALL_SERVER, ACTIVE_SERVER or INACTIVE_SERVER. More...
 

Static Public Member Functions

static getInstance ()
 Get singleton instance. More...
 

Data Fields

const ALL_SERVER = 0
 
const ACTIVE_SERVER = 1
 
const INACTIVE_SERVER = 2
 

Protected Member Functions

 __construct ()
 Singleton contructor. More...
 

Private Member Functions

 readServers ()
 Read all servers. More...
 

Private Attributes

ilDBInterface $db
 
array $servers
 

Static Private Attributes

static ilECSServerSettings $instance
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilECSServerSettings::__construct ( )
protected

Singleton contructor.

Definition at line 44 of file class.ilECSServerSettings.php.

References $DIC, and readServers().

45  {
46  global $DIC;
47 
48  $this->db = $DIC->database();
49 
50  $this->readServers();
51  }
readServers()
Read all servers.
global $DIC
Definition: shib_login.php:22
+ Here is the call graph for this function:

Member Function Documentation

◆ activeServerExists()

ilECSServerSettings::activeServerExists ( )

Check if there is any active server.

Returns
bool

Definition at line 67 of file class.ilECSServerSettings.php.

References getServers().

67  : bool
68  {
69  return count($this->getServers(static::ACTIVE_SERVER)) ? true : false;
70  }
getServers(int $server_type)
Get servers The function must be called with ALL_SERVER, ACTIVE_SERVER or INACTIVE_SERVER.
+ Here is the call graph for this function:

◆ getInstance()

◆ getServers()

ilECSServerSettings::getServers ( int  $server_type)

Get servers The function must be called with ALL_SERVER, ACTIVE_SERVER or INACTIVE_SERVER.

Returns
ilECSSetting[]

Definition at line 85 of file class.ilECSServerSettings.php.

References $server, $servers, and ilECSSetting\isEnabled().

Referenced by activeServerExists(), ilECSServerTableGUI\parse(), and serverExists().

85  : array
86  {
87  switch ($server_type) {
88  case static::ALL_SERVER:
89  return $this->servers;
90  break;
91  case static::ACTIVE_SERVER:
92  return array_filter($this->servers, static fn (ilECSSetting $server) => $server->isEnabled());
93  break;
94  case static::INACTIVE_SERVER:
95  return array_filter($this->servers, static fn (ilECSSetting $server) => !$server->isEnabled());
96  break;
97  default:
98  throw new InvalidArgumentException();
99  }
100  }
isEnabled()
is enabled
$server
Definition: shib_login.php:24
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ readServers()

ilECSServerSettings::readServers ( )
private

Read all servers.

Definition at line 105 of file class.ilECSServerSettings.php.

References $res, ilDBConstants\FETCHMODE_OBJECT, ilECSSetting\getInstanceByServerId(), and ILIAS\Repository\int().

Referenced by __construct().

105  : void
106  {
107  $query = 'SELECT server_id FROM ecs_server ' .
108  'ORDER BY title ';
109  $res = $this->db->query($query);
110 
111  $this->servers = array();
112  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
113  $server_id = (int) $row->server_id;
114  $this->servers[$server_id] = ilECSSetting::getInstanceByServerId($server_id);
115  }
116  }
$res
Definition: ltiservices.php:66
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ serverExists()

ilECSServerSettings::serverExists ( )

Check if there is any server.

Definition at line 75 of file class.ilECSServerSettings.php.

References getServers().

75  : bool
76  {
77  return count($this->getServers(static::ALL_SERVER)) ? true : false;
78  }
getServers(int $server_type)
Get servers The function must be called with ALL_SERVER, ACTIVE_SERVER or INACTIVE_SERVER.
+ Here is the call graph for this function:

Field Documentation

◆ $db

ilDBInterface ilECSServerSettings::$db
private

Definition at line 35 of file class.ilECSServerSettings.php.

◆ $instance

ilECSServerSettings ilECSServerSettings::$instance
staticprivate

Definition at line 32 of file class.ilECSServerSettings.php.

◆ $servers

array ilECSServerSettings::$servers
private

Definition at line 38 of file class.ilECSServerSettings.php.

Referenced by getServers().

◆ ACTIVE_SERVER

◆ ALL_SERVER

◆ INACTIVE_SERVER

const ilECSServerSettings::INACTIVE_SERVER = 2

Definition at line 30 of file class.ilECSServerSettings.php.


The documentation for this class was generated from the following file: