ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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 25 of file class.ilADTTest.php.

Member Function Documentation

◆ createPrimaryKeyb()

ilADTTest::createPrimaryKeyb ( )
protected

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

123  : bool
124  {
125  $this->id = $this->db->nextId("adt_test");
126 
127  // INSERT is only done if createPrimaryKey() returns TRUE!
128  return true;
129  }

◆ hasPrimary()

ilADTTest::hasPrimary ( )
protected

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

References $id.

118  : bool
119  {
120  return (bool) $this->id;
121  }

◆ initDBBridge()

ilADTTest::initDBBridge ( ilADTDBBridge  $a_adt_db)
protected

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

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

107  : void
108  {
109  $a_adt_db->setTable("adt_test");
110  $a_adt_db->setPrimary(array("id" => array("integer", $this->id)));
111  }
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 36 of file class.ilADTTest.php.

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

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

◆ parsePrimary()

ilADTTest::parsePrimary ( array  $a_args)
protected

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

References ILIAS\Repository\int().

113  : void
114  {
115  $this->id = (int) $a_args[0];
116  }
+ Here is the call graph for this function:

Field Documentation

◆ $id

int ilADTTest::$id
protected

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

Referenced by hasPrimary().

◆ $properties

ilADT ilADTTest::$properties
protected

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

◆ INTERESTS_IT

const ilADTTest::INTERESTS_IT = 2

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

◆ INTERESTS_LANGUAGES

const ilADTTest::INTERESTS_LANGUAGES = 1

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

◆ INTERESTS_NONE

const ilADTTest::INTERESTS_NONE = 0

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


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