ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
ilBuddySystemRelationStateFactory Class Reference

Class ilBuddySystemRelationStateFactory. More...

+ Collaboration diagram for ilBuddySystemRelationStateFactory:

Public Member Functions

 getInitialState ()
 
 getStatesAsOptionArray ($with_initial_state=false)
 
 getRendererByOwnerAndRelation ($owner_id, ilBuddySystemRelation $relation)
 

Static Public Member Functions

static getInstance ()
 

Protected Member Functions

 __construct ()
 

Protected Attributes

 $lng
 

Static Protected Attributes

static $instance
 
static $valid_states
 
static $state_option_array
 

Detailed Description

Constructor & Destructor Documentation

◆ __construct()

ilBuddySystemRelationStateFactory::__construct ( )
protected

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

References $DIC.

36  {
37  global $DIC;
38 
39  $this->lng = $DIC['lng'];
40  }
global $DIC
Definition: saml.php:7

Member Function Documentation

◆ getInitialState()

ilBuddySystemRelationStateFactory::getInitialState ( )
Returns
ilBuddySystemRelationState
Exceptions
ilBuddySystemException

Definition at line 92 of file class.ilBuddySystemRelationStateFactory.php.

References $state.

93  {
94  foreach ($this->getValidStates() as $state) {
95  if ($state->isInitial()) {
96  return $state;
97  }
98  }
99 
100  throw new ilBuddySystemException("Could not find an initial state class");
101  }
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10

◆ getInstance()

static ilBuddySystemRelationStateFactory::getInstance ( )
static
Returns
self

Definition at line 45 of file class.ilBuddySystemRelationStateFactory.php.

Referenced by ilBuddySystemGUI\__construct(), ilBuddySystemLinkButton\getHtml(), ilBuddyList\getRelationByUserId(), and ilBuddySystemRelationsTableGUI\initFilter().

46  {
47  if (null === self::$instance) {
48  self::$instance = new self;
49  }
50 
51  return self::$instance;
52  }
+ Here is the caller graph for this function:

◆ getRendererByOwnerAndRelation()

ilBuddySystemRelationStateFactory::getRendererByOwnerAndRelation (   $owner_id,
ilBuddySystemRelation  $relation 
)
Parameters
int$owner_id
ilBuddySystemRelation$relation
Returns
ilBuddySystemRelationStateButtonRenderer
Exceptions
ilBuddySystemException

Definition at line 130 of file class.ilBuddySystemRelationStateFactory.php.

References ilBuddySystemRelation\getState().

131  {
132  $state_class = get_class($relation->getState());
133  $renderer_class = $state_class . 'ButtonRenderer';
134  $renderer_path = "Services/Contact/BuddySystem/classes/states/renderer/class.{$renderer_class}.php";
135 
136  if (!file_exists($renderer_path)) {
137  throw new ilBuddySystemException(sprintf("Could not find a renderer file for state: %s", $state_class));
138  }
139 
140  require_once $renderer_path;
141  if (!class_exists($renderer_class)) {
142  throw new ilBuddySystemException(sprintf("Could not find a renderer class for state: %s in file: %s", $state_class, $renderer_path));
143  }
144 
145  return new $renderer_class($owner_id, $relation);
146  }
+ Here is the call graph for this function:

◆ getStatesAsOptionArray()

ilBuddySystemRelationStateFactory::getStatesAsOptionArray (   $with_initial_state = false)
Parameters
bool$with_initial_state
Returns
array

Definition at line 107 of file class.ilBuddySystemRelationStateFactory.php.

References PHPMailer\PHPMailer\$options, and $state.

108  {
109  if (null !== self::$state_option_array[$with_initial_state]) {
110  return self::$state_option_array[$with_initial_state];
111  }
112 
113  $options = array();
114 
115  foreach ($this->getValidStates() as $state) {
116  if ($with_initial_state || !$state->isInitial()) {
117  $options[get_class($state)] = $this->lng->txt('buddy_bs_state_' . strtolower($state->getName()));
118  }
119  }
120 
121  return (self::$state_option_array[$with_initial_state] = $options);
122  }
if(!array_key_exists('stateid', $_REQUEST)) $state
Handle linkback() response from LinkedIn.
Definition: linkback.php:10

Field Documentation

◆ $instance

ilBuddySystemRelationStateFactory::$instance
staticprotected

Definition at line 15 of file class.ilBuddySystemRelationStateFactory.php.

◆ $lng

ilBuddySystemRelationStateFactory::$lng
protected

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

◆ $state_option_array

ilBuddySystemRelationStateFactory::$state_option_array
staticprotected

Definition at line 25 of file class.ilBuddySystemRelationStateFactory.php.

◆ $valid_states

ilBuddySystemRelationStateFactory::$valid_states
staticprotected

Definition at line 20 of file class.ilBuddySystemRelationStateFactory.php.


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