ILIAS  trunk Revision v5.2.0beta1-34115-g3a2438be29
ilADTTest Class Reference

This is a ADT-based example object It has all supported ADTs and shows DB sequence-handling. More...

+ Inheritance diagram for ilADTTest:
+ Collaboration diagram for ilADTTest:

Data Fields

const INTERESTS_NONE = 0
 
const INTERESTS_LANGUAGES = 1
 
const INTERESTS_IT = 2
 

Protected Member Functions

 initProperties ()
 
 initDBBridge (ilADTDBBridge $a_adt_db)
 
 parsePrimary (array $a_args)
 
 hasPrimary ()
 
 createPrimaryKeyb ()
 
- Protected Member Functions inherited from ilADTBasedObject
 initProperties ()
 Init properties (aka set ADT definition) More...
 
 parsePrimary (array $a_args)
 Parse incoming primary key. More...
 
 hasPrimary ()
 Check if currently has primary. More...
 
 createPrimaryKeyb ()
 Create new primary key, e.g. More...
 
 initDBBridge (ilADTDBBridge $a_adt_db)
 Init (properties) DB bridge. More...
 
 initActiveRecordInstance ()
 Init active record helper for current table, primary and properties. More...
 

Protected Attributes

int $id
 
ilADT $properties
 
- Protected Attributes inherited from ilADTBasedObject
ilADT $properties
 
array $db_errors = []
 
ilDBInterface $db
 
ilLanguage $lng
 

Additional Inherited Members

- Public Member Functions inherited from ilADTBasedObject
 __construct ()
 Constructor Tries to read record from DB, in accordance to current ILIAS behaviour. More...
 
 getProperties ()
 Get all properties. More...
 
 isValid ()
 Validate. More...
 
 __call ($a_method, $a_value)
 Get property magic method ("get<PropertyName>()") Setters are type-specific and cannot be magic. More...
 
 read ()
 Read record. More...
 
 create ()
 Create record (only if valid) More...
 
 update ()
 Update record (only if valid) More...
 
 delete ()
 Delete record. More...
 
 getDBErrors ()
 Get DB errors. More...
 
 translateDBErrorCodes (array $a_codes)
 Translate DB error codes. More...
 
 getAllTranslatedErrors (string $delimiter="\)
 Get translated error codes (DB, Validation) More...
 

Detailed Description

This is a ADT-based example object It has all supported ADTs and shows DB sequence-handling.

Definition at line 9 of file class.ilADTTest.php.

Member Function Documentation

◆ createPrimaryKeyb()

ilADTTest::createPrimaryKeyb ( )
protected

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

107  : bool
108  {
109  $this->id = $this->db->nextId("adt_test");
110 
111  // INSERT is only done if createPrimaryKey() returns TRUE!
112  return true;
113  }

◆ hasPrimary()

ilADTTest::hasPrimary ( )
protected

Definition at line 102 of file class.ilADTTest.php.

References $id.

102  : bool
103  {
104  return (bool) $this->id;
105  }

◆ initDBBridge()

ilADTTest::initDBBridge ( ilADTDBBridge  $a_adt_db)
protected

Definition at line 91 of file class.ilADTTest.php.

References ilADTDBBridge\setPrimary(), and ilADTDBBridge\setTable().

91  : void
92  {
93  $a_adt_db->setTable("adt_test");
94  $a_adt_db->setPrimary(array("id" => array("integer", $this->id)));
95  }
setPrimary(array $a_value)
Set primary fields (in MDB2 format)
setTable(string $a_table)
+ Here is the call graph for this function:

◆ initProperties()

ilADTTest::initProperties ( )
protected

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

References $factory, $lang, ilADTFactory\getInstance(), and ILIAS\Repository\lng().

20  : ilADT
21  {
22  // this could be generated from XML or code comments or whatever
23 
25 
26  $properties_def = $factory->getDefinitionInstanceByType("Group");
27 
28  $name = $factory->getDefinitionInstanceByType("Text");
29  $name->setMaxLength(255);
30  $properties_def->addElement("name", $name);
31 
32  $status = $factory->getDefinitionInstanceByType("Boolean");
33  $properties_def->addElement("active", $status);
34 
35  // example options from ilLanguage
36  $this->lng->loadLanguageModule("meta");
37  $options = array();
38  foreach ($this->lng->getInstalledLanguages() as $lang) {
39  $options[$lang] = $this->lng->txt("meta_l_" . $lang);
40  }
41 
42  $lang = $factory->getDefinitionInstanceByType("Enum");
43  $lang->setNumeric(false);
44  $lang->setOptions($options);
45  $properties_def->addElement("lang", $lang);
46 
47  $age = $factory->getDefinitionInstanceByType("Integer");
48  $age->setMin(0);
49  $age->setMax(120);
50  $properties_def->addElement("age", $age);
51 
52  $weight = $factory->getDefinitionInstanceByType("Float");
53  $weight->setMin(0);
54  $weight->setMax(500);
55  $properties_def->addElement("weight", $weight);
56 
57  // null?
58  $home = $factory->getDefinitionInstanceByType("Location");
59  $properties_def->addElement("home", $home);
60 
61  $tags = $factory->getDefinitionInstanceByType("MultiText");
62  $tags->setMaxLength(255);
63  $tags->setMaxSize(5);
64  $properties_def->addElement("tags", $tags);
65 
66  $options = array(
67  self::INTERESTS_NONE => $this->lng->txt("test_interests_none"),
68  self::INTERESTS_LANGUAGES => $this->lng->txt("test_interests_languages"),
69  self::INTERESTS_IT => $this->lng->txt("test_interests_it")
70  );
71 
72  $intr = $factory->getDefinitionInstanceByType("MultiEnum");
73  $intr->setOptions($options);
74  $properties_def->addElement("interests", $intr);
75 
76  $date = $factory->getDefinitionInstanceByType("Date");
77  $properties_def->addElement("entry_date", $date);
78 
79  $dt = $factory->getDefinitionInstanceByType("DateTime");
80  $properties_def->addElement("last_login", $dt);
81 
82  // convert ADT definitions to proper ADTs
83  return $factory->getInstanceByDefinition($properties_def);
84  }
$factory
Definition: saml1-acs.php:57
ADT base class.
Definition: class.ilADT.php:11
$lang
Definition: xapiexit.php:26
+ Here is the call graph for this function:

◆ parsePrimary()

ilADTTest::parsePrimary ( array  $a_args)
protected

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

References ILIAS\Repository\int().

97  : void
98  {
99  $this->id = (int) $a_args[0];
100  }
+ Here is the call graph for this function:

Field Documentation

◆ $id

int ilADTTest::$id
protected

Definition at line 11 of file class.ilADTTest.php.

Referenced by hasPrimary().

◆ $properties

ilADT ilADTTest::$properties
protected

Definition at line 12 of file class.ilADTTest.php.

◆ INTERESTS_IT

const ilADTTest::INTERESTS_IT = 2

Definition at line 16 of file class.ilADTTest.php.

◆ INTERESTS_LANGUAGES

const ilADTTest::INTERESTS_LANGUAGES = 1

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

◆ INTERESTS_NONE

const ilADTTest::INTERESTS_NONE = 0

Definition at line 14 of file class.ilADTTest.php.


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