ILIAS  release_5-1 Revision 5.0.0-5477-g43f3e3fab5f
ilADTTest Class Reference

This is a ADT-based example object. 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 ()
 Init properties (aka set ADT definition) More...
 
 initDBBridge (ilADTGroupDBBridge $a_adt_db)
 Init (properties) DB bridge. More...
 
 parsePrimary (array $a_args)
 Parse incoming primary key. More...
 
 hasPrimary ()
 Check if currently has primary. More...
 
 createPrimaryKey ()
 Create new primary key, e.g. More...
 
- 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...
 
 createPrimaryKey ()
 Create new primary key, e.g. More...
 
 initDBBridge (ilADTGroupDBBridge $a_adt_db)
 Init (properties) DB bridge. More...
 
 initActiveRecordInstance ()
 Init active record helper for current table, primary and properties. More...
 

Protected Attributes

 $id
 
 $properties
 
- Protected Attributes inherited from ilADTBasedObject
 $properties = array()
 
 $db_errors = array()
 

Additional Inherited Members

- Public Member Functions inherited from ilADTBasedObject
 __construct ()
 Constructor. More...
 
 getProperties ()
 Get all properties. More...
 
 isValid ()
 Validate. More...
 
 __call ($a_method, $a_value)
 Get property magic method ("get<PropertyName>()") 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 ($delimiter="\n")
 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 10 of file class.ilADTTest.php.

Member Function Documentation

◆ createPrimaryKey()

ilADTTest::createPrimaryKey ( )
protected

Create new primary key, e.g.

sequence

Returns
bool

Reimplemented from ilADTBasedObject.

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

115 {
116 global $ilDB;
117
118 $this->id = $ilDB->nextId("adt_test");
119
120 // INSERT is only done if createPrimaryKey() returns TRUE!
121 return true;
122 }
global $ilDB

References $ilDB.

◆ hasPrimary()

ilADTTest::hasPrimary ( )
protected

Check if currently has primary.

Returns
bool

Reimplemented from ilADTBasedObject.

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

110 {
111 return (bool)$this->id;
112 }

References $id.

◆ initDBBridge()

ilADTTest::initDBBridge ( ilADTGroupDBBridge  $a_adt_db)
protected

Init (properties) DB bridge.

Parameters
ilADTGroupDBBridge$a_adt_db

Reimplemented from ilADTBasedObject.

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

99 {
100 $a_adt_db->setTable("adt_test");
101 $a_adt_db->setPrimary(array("id"=>array("integer", $this->id)));
102 }
setTable($a_table)
Set table name.
setPrimary(array $a_value)
Set primary fields (in MDB2 format)

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

+ Here is the call graph for this function:

◆ initProperties()

ilADTTest::initProperties ( )
protected

Init properties (aka set ADT definition)

Returns
ilADT

Reimplemented from ilADTBasedObject.

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

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

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

+ Here is the call graph for this function:

◆ parsePrimary()

ilADTTest::parsePrimary ( array  $a_args)
protected

Parse incoming primary key.

See also
__construct()
Parameters
array$a_args

Reimplemented from ilADTBasedObject.

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

105 {
106 $this->id = (int)$a_args[0];
107 }

Field Documentation

◆ $id

ilADTTest::$id
protected

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

Referenced by hasPrimary().

◆ $properties

ilADTTest::$properties
protected

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

◆ INTERESTS_IT

const ilADTTest::INTERESTS_IT = 2

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

◆ INTERESTS_LANGUAGES

const ilADTTest::INTERESTS_LANGUAGES = 1

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

◆ INTERESTS_NONE

const ilADTTest::INTERESTS_NONE = 0

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


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