ILIAS  trunk Revision v13.0_alpha-62-g3b72d83f2e5
ILIAS\Questions\AnswerForm\Factory Class Reference
+ Collaboration diagram for ILIAS\Questions\AnswerForm\Factory:

Public Member Functions

 __construct (private readonly UuidFactory $uuid_factory, array $available_answer_form_types)
 
 getAvailableDefinitions ()
 
 getDefinitionForClass (string $class)
 
 getAnswerFormTypesArrayForSelect (Language $lng)
 
 getHashedClass (string $class)
 
 getTypeDefinitionFromSelectValue (string $value)
 
 getDefaultTypeGenericProperties (Uuid $question_id, Definition $type_definition, ?Uuid $answer_form_id=null)
 
 buildTypeGenericPropertiesFromDatabase (array $db_values)
 

Private Attributes

readonly array $available_answer_form_types
 

Detailed Description

Definition at line 28 of file Factory.php.

Constructor & Destructor Documentation

◆ __construct()

ILIAS\Questions\AnswerForm\Factory::__construct ( private readonly UuidFactory  $uuid_factory,
array  $available_answer_form_types 
)
Parameters
array<

ILIAS\Questions\AnswerForm\Definition> $available_answer_form_types

Definition at line 38 of file Factory.php.

41 {
42 $this->available_answer_form_types = array_reduce(
44 function (array $c, Definition $v) {
45 $c[$this->getHashedClass($v::class)] = $v;
46 return $c;
47 },
48 []
49 );
50 }
readonly array $available_answer_form_types
Definition: Factory.php:33

References ILIAS\Questions\AnswerForm\Factory\$available_answer_form_types, Vendor\Package\$c, and ILIAS\Questions\AnswerForm\Factory\getHashedClass().

+ Here is the call graph for this function:

Member Function Documentation

◆ buildTypeGenericPropertiesFromDatabase()

ILIAS\Questions\AnswerForm\Factory::buildTypeGenericPropertiesFromDatabase ( array  $db_values)

Definition at line 114 of file Factory.php.

116 : TypeGenericProperties {
117 return new TypeGenericProperties(
118 $this->uuid_factory->fromString($db_values['id']),
119 $this->uuid_factory->fromString($db_values['question_id']),
120 $this->getDefinitionForClass($db_values['type']),
121 $db_values['available_points'],
122 $db_values['image_size'],
123 $db_values['shuffle_answer_options'] === 1,
124 $db_values['additional_text'],
125 $db_values['additional_text_legacy']
126 );
127 }

◆ getAnswerFormTypesArrayForSelect()

ILIAS\Questions\AnswerForm\Factory::getAnswerFormTypesArrayForSelect ( Language  $lng)
Returns
array<string, \ILIAS\Questions\AnswerForm\Definition>

Definition at line 74 of file Factory.php.

76 : array {
77 return array_reduce(
78 $this->available_answer_form_types,
79 function (array $c, Definition $v) use ($lng): array {
80 $c[$this->getHashedClass($v::class)] = $v->getLabel($lng);
81 return $c;
82 },
83 []
84 );
85 }
global $lng
Definition: privfeed.php:26

◆ getAvailableDefinitions()

ILIAS\Questions\AnswerForm\Factory::getAvailableDefinitions ( )
Returns
array<string>

Definition at line 56 of file Factory.php.

56 : array
57 {
58 return array_values($this->available_answer_form_types);
59 }

◆ getDefaultTypeGenericProperties()

ILIAS\Questions\AnswerForm\Factory::getDefaultTypeGenericProperties ( Uuid  $question_id,
Definition  $type_definition,
?Uuid  $answer_form_id = null 
)

Definition at line 102 of file Factory.php.

106 : TypeGenericProperties {
107 return new TypeGenericProperties(
108 $answer_form_id ?? $this->uuid_factory->uuid4(),
109 $question_id,
110 $type_definition
111 );
112 }

◆ getDefinitionForClass()

ILIAS\Questions\AnswerForm\Factory::getDefinitionForClass ( string  $class)

Definition at line 61 of file Factory.php.

63 : Definition {
64 $definition = $this->available_answer_form_types[$this->getHashedClass($class)] ?? null;
65 if ($definition === null) {
66 throw new InvalidArgumentException('This type of answer form does not exist.');
67 }
68 return $definition;
69 }

◆ getHashedClass()

ILIAS\Questions\AnswerForm\Factory::getHashedClass ( string  $class)

Definition at line 87 of file Factory.php.

87 : string
88 {
89 return md5($class);
90 }

Referenced by ILIAS\Questions\AnswerForm\Factory\__construct().

+ Here is the caller graph for this function:

◆ getTypeDefinitionFromSelectValue()

ILIAS\Questions\AnswerForm\Factory::getTypeDefinitionFromSelectValue ( string  $value)

Definition at line 92 of file Factory.php.

94 : Definition {
95 $type_definition = $this->available_answer_form_types[$value] ?? null;
96 if ($type_definition === null) {
97 throw new InvalidArgumentException('This type of answer form does not exist.');
98 }
99 return $type_definition;
100 }

Field Documentation

◆ $available_answer_form_types

array< string, \ILIAS\Questions\AnswerForm\Definition > ILIAS\Questions\AnswerForm\Factory::$available_answer_form_types
private

Definition at line 33 of file Factory.php.

Referenced by ILIAS\Questions\AnswerForm\Factory\__construct().


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