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.php73
1 files changed, 53 insertions, 20 deletions
diff --git a/engine/classes/ElggExtender.php b/engine/classes/ElggExtender.php
index d9a6a52ef..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,11 +15,30 @@
* @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 implements
- Exportable
-{
-
+abstract class ElggExtender extends ElggData {
+
+ /**
+ * (non-PHPdoc)
+ *
+ * @see ElggData::initializeAttributes()
+ *
+ * @return void
+ */
+ protected function initializeAttributes() {
+ parent::initializeAttributes();
+
+ $this->attributes['type'] = NULL;
+ }
+
/**
* Returns an attribute
*
@@ -29,7 +47,7 @@ abstract class ElggExtender extends ElggData implements
* @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']) {
@@ -44,8 +62,8 @@ abstract class ElggExtender extends ElggData implements
break;
default :
- $msg = sprintf(elgg_echo('InstallationException:TypeNotSupported'),
- $this->attributes['value_type']);
+ $msg = elgg_echo('InstallationException:TypeNotSupported', array(
+ $this->attributes['value_type']));
throw new InstallationException($msg);
break;
@@ -76,27 +94,42 @@ abstract class ElggExtender extends ElggData implements
}
/**
- * Return the entity this describes.
+ * Get the GUID of the extender's owner entity.
*
- * @return ElggEntity The enttiy
+ * @return int The owner GUID
*/
- public function getEntity() {
- return get_entity($this->entity_guid);
+ public function getOwnerGUID() {
+ return $this->owner_guid;
}
/**
- * Save this data to the appropriate database table.
+ * Return the guid of the entity's owner.
*
- * @return bool
+ * @return int The owner GUID
+ * @deprecated 1.8 Use getOwnerGUID
*/
- abstract public function save();
+ public function getOwner() {
+ elgg_deprecated_notice("ElggExtender::getOwner deprecated for ElggExtender::getOwnerGUID", 1.8);
+ return $this->getOwnerGUID();
+ }
/**
- * Delete this data.
+ * Get the entity that owns this extender
*
- * @return bool
+ * @return ElggEntity
+ */
+ public function getOwnerEntity() {
+ return get_entity($this->owner_guid);
+ }
+
+ /**
+ * Get the entity this describes.
+ *
+ * @return ElggEntity The entity
*/
- abstract public function delete();
+ public function getEntity() {
+ return get_entity($this->entity_guid);
+ }
/**
* Returns if a user can edit this extended data.
@@ -138,7 +171,7 @@ abstract class ElggExtender extends ElggData implements
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));