Methods of Midgard Objects
- Object management methods
- Attachment handling methods
- Parameter handling methods
- Multilingual content methods
- Object instances in Classic API
- Full instances
All data in Midgard is available in object-oriented fashion using the MgdSchema data abstration system. The content objects in Midgard provide a consistent programming API for manipulating them.
Object management methods
- $object->create
- $object->delete
- $object->getsitegroup
- $object->guid
- $object->parent
- $object->setscore
- $object->setsitegroup
- $object->settype
- $object->update
Attachment handling methods
- $object->createattachment
- $object->deleteattachment
- $object->getattachment
- $object->listattachments
- $object->openattachment
- $object->serveattachment
- $object->updateattachment
Parameter handling methods
Multilingual content methods
Object instances in Classic API
Fetchables
The objects returned by the mgd_list_() functions are "truncated" due to obvious performance issue) and have only the following five common members:
<?php
// General object prototype for fetchables
class MidgardFetchable
{
$__table__; // PRIVATE!
$__res__; // PRIVATE!
$N; // Number of items in the list
$id; // id of the current instance
$sitegroup; // sitegroup of the current instance
fetch(); // The only method: fetches the next
// instance in the result list
}
Both $N and $__res__ are specific only to this truncated form of Midgard objects and are used internally by the fetch() method. Most specific Midgard classes currently have more members than the ones mentioned above. Those additional members help easily building lists, but may become deprecated in the future.
Full instances
The full instances of Midgard classes must be obtained with the appropriate mgd_get_() function. Those mgd_get_() functions return a fully fledged object without $N and $__res__, but with all the members and methods properties described in the manual chapter explaining the object.
Although Midgard classes are not real PHP classes, you can sub-class them and thus extend their functionality:
class Expert extends MidgardPerson
{
function Expert($id)
{
$mgd = mgd_get_person($id);
if ($mgd)
{
foreach (get_object_vars($mgd) as $k=>$v)
{
$this->$k = $v;
}
}
}
/* add your own methods here */
}
