ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables 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 43 of file class.ilECSServerSettings.php.

References $DIC, and readServers().

44  {
45  global $DIC;
46 
47  $this->db = $DIC->database();
48 
49  $this->readServers();
50  }
global $DIC
Definition: feed.php:28
readServers()
Read all servers.
+ 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 66 of file class.ilECSServerSettings.php.

References getServers().

66  : bool
67  {
68  return count($this->getServers(static::ACTIVE_SERVER)) ? true : false;
69  }
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 84 of file class.ilECSServerSettings.php.

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

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

84  : array
85  {
86  switch ($server_type) {
87  case static::ALL_SERVER:
88  return $this->servers;
89  break;
90  case static::ACTIVE_SERVER:
91  return array_filter($this->servers, static fn (ilECSSetting $server) => $server->isEnabled());
92  break;
93  case static::INACTIVE_SERVER:
94  return array_filter($this->servers, static fn (ilECSSetting $server) => !$server->isEnabled());
95  break;
96  default:
97  throw new InvalidArgumentException();
98  }
99  }
isEnabled()
is enabled
$server
+ 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 104 of file class.ilECSServerSettings.php.

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

Referenced by __construct().

104  : void
105  {
106  $query = 'SELECT server_id FROM ecs_server ' .
107  'ORDER BY title ';
108  $res = $this->db->query($query);
109 
110  $this->servers = array();
111  while ($row = $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)) {
112  $server_id = (int) $row->server_id;
113  $this->servers[$server_id] = ilECSSetting::getInstanceByServerId($server_id);
114  }
115  }
$res
Definition: ltiservices.php:69
static getInstanceByServerId(int $a_server_id)
Get singleton instance per server.
$query
+ 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 74 of file class.ilECSServerSettings.php.

References getServers().

74  : bool
75  {
76  return count($this->getServers(static::ALL_SERVER)) ? true : false;
77  }
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 34 of file class.ilECSServerSettings.php.

◆ $instance

ilECSServerSettings ilECSServerSettings::$instance
staticprivate

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

◆ $servers

array ilECSServerSettings::$servers
private

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

Referenced by getServers().

◆ ACTIVE_SERVER

◆ ALL_SERVER

◆ INACTIVE_SERVER

const ilECSServerSettings::INACTIVE_SERVER = 2

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


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