aboutsummaryrefslogtreecommitdiff
path: root/engine/classes/ElggExtender.php
diff options
context:
space:
mode:
Diffstat (limited to 'engine/classes/ElggExtender.php')
-rw-r--r--engine/classes/ElggExtender.php49
1 files changed, 37 insertions, 12 deletions
diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php
index 78ccea395..25aba354f 100644
--- a/engine/classes/ElggExtender.php
+++ b/engine/classes/ElggExtender.php
@@ -3,8 +3,7 @@
* The base class for ElggEntity extenders.
*
* Extenders allow you to attach extended information to an
- * ElggEntity. Core supports two: ElggAnnotation, ElggMetadata,
- * and ElggRelationship
+ * ElggEntity. Core supports two: ElggAnnotation and ElggMetadata.
*
* Saving the extender data to database is handled by the child class.
*
@@ -16,13 +15,28 @@
* @link http://docs.elgg.org/DataModel/Extenders
* @see ElggAnnotation
* @see ElggMetadata
+ *
+ * @property string $type annotation or metadata (read-only after save)
+ * @property int $id The unique identifier (read-only)
+ * @property int $entity_guid The GUID of the entity that this extender describes
+ * @property int $access_id Specifies the visibility level of this extender
+ * @property string $name The name of this extender
+ * @property mixed $value The value of the extender (int or string)
+ * @property int $time_created A UNIX timestamp of when the extender was created (read-only, set on first save)
*/
-abstract class ElggExtender extends ElggData
-{
+abstract class ElggExtender extends ElggData {
+
+ /**
+ * (non-PHPdoc)
+ *
+ * @see ElggData::initializeAttributes()
+ *
+ * @return void
+ */
protected function initializeAttributes() {
parent::initializeAttributes();
- $this->attributes['type'] = '';
+ $this->attributes['type'] = NULL;
}
/**
@@ -33,7 +47,7 @@ abstract class ElggExtender extends ElggData
* @return mixed
*/
protected function get($name) {
- if (isset($this->attributes[$name])) {
+ if (array_key_exists($name, $this->attributes)) {
// Sanitise value if necessary
if ($name == 'value') {
switch ($this->attributes['value_type']) {
@@ -80,27 +94,38 @@ abstract class ElggExtender extends ElggData
}
/**
+ * Get the GUID of the extender's owner entity.
+ *
+ * @return int The owner GUID
+ */
+ public function getOwnerGUID() {
+ return $this->owner_guid;
+ }
+
+ /**
* Return the guid of the entity's owner.
*
* @return int The owner GUID
+ * @deprecated 1.8 Use getOwnerGUID
*/
public function getOwner() {
- return $this->owner_guid;
+ elgg_deprecated_notice("ElggExtender::getOwner deprecated for ElggExtender::getOwnerGUID", 1.8);
+ return $this->getOwnerGUID();
}
/**
- * Returns the ElggEntity or child object of the owner of the entity.
+ * Get the entity that owns this extender
*
- * @return ElggEntity The owning user
+ * @return ElggEntity
*/
public function getOwnerEntity() {
return get_entity($this->owner_guid);
}
/**
- * Return the entity this describes.
+ * Get the entity this describes.
*
- * @return ElggEntity The enttiy
+ * @return ElggEntity The entity
*/
public function getEntity() {
return get_entity($this->entity_guid);
@@ -146,7 +171,7 @@ abstract class ElggExtender extends ElggData
public function export() {
$uuid = get_uuid_from_object($this);
- $meta = new ODDMetadata($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'],
+ $meta = new ODDMetaData($uuid, guid_to_uuid($this->entity_guid), $this->attributes['name'],
$this->attributes['value'], $this->attributes['type'], guid_to_uuid($this->owner_guid));
$meta->setAttribute('published', date("r", $this->time_created));