35 if (!is_numeric(
$row)) {
36 throw new \InvalidArgumentException(
"Constructor accepts only a \stdClass or null.");
43 throw new \InvalidArgumentException(
"Relationship not found with ID $id");
51 $this->attributes[
'id'] = (int)$this->attributes[
'id'];
62 parent::initializeAttributes();
64 $this->attributes[
'id'] = null;
65 $this->attributes[
'guid_one'] = null;
66 $this->attributes[
'relationship'] = null;
67 $this->attributes[
'guid_two'] = null;
102 if (array_key_exists(
$name, $this->attributes)) {
103 return $this->attributes[
$name];
139 throw new \IOException(
"Unable to save new " . get_class());
150 public function delete() {
171 if (isset($CONFIG->relationship_url_handler[
$subtype])) {
172 $function = $CONFIG->relationship_url_handler[
$subtype];
174 if (isset($CONFIG->relationship_url_handler[
'all'])) {
175 $function = $CONFIG->relationship_url_handler[
'all'];
178 if (is_callable($function)) {
179 $url = call_user_func($function, $this);
188 $params = array(
'relationship' => $this);
200 $object->subject_guid = $this->guid_one;
201 $object->relationship = $this->relationship;
202 $object->object_guid = $this->guid_two;
204 $params = array(
'relationship' => $this);
241 $relationship->setAttribute(
'uuid', $uuid);
243 return $relationship;
260 throw new \InvalidParameterException(
"import() passed an unexpected ODD class");
263 $uuid_one =
$data->getAttribute(
'uuid1');
264 $uuid_two =
$data->getAttribute(
'uuid2');
269 if (($entity1) && ($entity2)) {
271 $this->attributes[
'guid_one'] = $entity1->getGUID();
272 $this->attributes[
'guid_two'] = $entity2->getGUID();
277 $relationship =
$data->getAttribute(
'type');
280 $this->attributes[
'relationship'] = $relationship;
284 throw new \ImportException(
"There was a problem saving " . get_class());
325 return 'relationship';
335 return $this->relationship;
$object
These two snippets demonstrates triggering an event and how to register for that event.
export()
Export this relationship.
getTimeCreated()
Returns the UNIX epoch time that this entity was created.
get_relationship($id)
Get a relationship by its ID.
get_uuid_from_object($object)
Get a UUID from a given object.
if($guid==elgg_get_logged_in_user_guid()) $name
getSystemLogID()
Return an identification for the object for storage in the system log.
get_entity_from_uuid($uuid)
This function attempts to retrieve a previously imported entity via its UUID.
__set($name, $value)
Set an attribute of the relationship.
__get($name)
Get an attribute of the relationship.
getType()
Return a type of the object - eg.
initializeAttributes()
(non-PHPdoc)
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
delete_relationship($id)
Delete a relationship by its ID.
__construct($row=null)
Create a relationship object.
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
guid_to_uuid($guid)
Generate a UUID from a given GUID.
getObjectFromID($id)
For a given ID, return the object associated with it.
getExportableValues()
Return an array of fields which can be exported.
save()
Save the relationship.
if(!$collection_name) $id
getURL()
Get a URL for this relationship.
getSubtype()
Return a subtype.