ILIAS  release_5-2 Revision v5.2.25-18-g3f80b828510
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.

36 {
37 global $DIC;
38
39 $this->lng = $DIC['lng'];
40 }
global $DIC

References $DIC.

Member Function Documentation

◆ getInitialState()

ilBuddySystemRelationStateFactory::getInitialState ( )
Returns
ilBuddySystemRelationState
Exceptions
ilBuddySystemException

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

98 {
99 foreach($this->getValidStates() as $state)
100 {
101 if($state->isInitial())
102 {
103 return $state;
104 }
105 }
106
107 throw new ilBuddySystemException("Could not find an initial state class");
108 }

◆ getInstance()

static ilBuddySystemRelationStateFactory::getInstance ( )
static
Returns
self

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

46 {
47 if(null === self::$instance)
48 {
49 self::$instance = new self;
50 }
51
52 return self::$instance;
53 }

References $instance.

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

+ 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 140 of file class.ilBuddySystemRelationStateFactory.php.

141 {
142 $state_class = get_class($relation->getState());
143 $renderer_class = $state_class . 'ButtonRenderer';
144 $renderer_path = "Services/Contact/BuddySystem/classes/states/renderer/class.{$renderer_class}.php";
145
146 if(!file_exists($renderer_path))
147 {
148 throw new ilBuddySystemException(sprintf("Could not find a renderer file for state: %s", $state_class));
149 }
150
151 require_once $renderer_path;
152 if(!class_exists($renderer_class))
153 {
154 throw new ilBuddySystemException(sprintf("Could not find a renderer class for state: %s in file: %s", $state_class, $renderer_path));
155 }
156
157 return new $renderer_class($owner_id, $relation);
158 }
sprintf('%.4f', $callTime)

References ilBuddySystemRelation\getState(), and sprintf.

+ 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 114 of file class.ilBuddySystemRelationStateFactory.php.

115 {
116 if(null !== self::$state_option_array[$with_initial_state])
117 {
118 return self::$state_option_array[$with_initial_state];
119 }
120
121 $options = array();
122
123 foreach($this->getValidStates() as $state)
124 {
125 if($with_initial_state || !$state->isInitial())
126 {
127 $options[get_class($state)] = $this->lng->txt('buddy_bs_state_' . strtolower($state->getName()));
128 }
129 }
130
131 return (self::$state_option_array[$with_initial_state] = $options);
132 }
if(!is_array($argv)) $options

References $options.

Field Documentation

◆ $instance

ilBuddySystemRelationStateFactory::$instance
staticprotected

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

Referenced by getInstance().

◆ $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: