ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
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 ()
 
 initDBBridge (ilADTGroupDBBridge $a_adt_db)
 
 parsePrimary (array $a_args)
 
 hasPrimary ()
 
 createPrimaryKey ()
 
- 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="\)
 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

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

References $DIC, and $ilDB.

116  {
117  global $DIC;
118 
119  $ilDB = $DIC['ilDB'];
120 
121  $this->id = $ilDB->nextId("adt_test");
122 
123  // INSERT is only done if createPrimaryKey() returns TRUE!
124  return true;
125  }
global $DIC
Definition: saml.php:7
global $ilDB

◆ hasPrimary()

ilADTTest::hasPrimary ( )
protected

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

References $id.

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

◆ initDBBridge()

ilADTTest::initDBBridge ( ilADTGroupDBBridge  $a_adt_db)
protected

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

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

100  {
101  $a_adt_db->setTable("adt_test");
102  $a_adt_db->setPrimary(array("id" => array("integer", $this->id)));
103  }
+ Here is the call graph for this function:

◆ initProperties()

ilADTTest::initProperties ( )
protected

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

References $DIC, $factory, $lang, $lng, $name, PHPMailer\PHPMailer\$options, $tags, and ilADTFactory\getInstance().

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

◆ parsePrimary()

ilADTTest::parsePrimary ( array  $a_args)
protected

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

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

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: