Elgg  Version 4.x
ElggMetadata.php
Go to the documentation of this file.
1 <?php
2 
11 class ElggMetadata extends ElggExtender {
12 
16  protected function initializeAttributes() {
17  parent::initializeAttributes();
18 
19  $this->attributes['type'] = 'metadata';
20  $this->attributes['access_id '] = ACCESS_PUBLIC;
21  }
22 
28  public function __construct(stdClass $row = null) {
29  $this->initializeAttributes();
30 
31  if ($row) {
32  foreach ((array) $row as $key => $value) {
33  $this->$key = $value;
34  }
35  }
36  }
37 
45  public function canEdit($user_guid = 0) {
46  return has_access_to_entity($this->getEntity());
47  }
48 
54  public function save() : bool {
55  if (!$this->id) {
56  return (bool) _elgg_services()->metadataTable->create($this);
57  }
58 
59  return _elgg_services()->metadataTable->update($this);
60  }
61 
67  public function delete() {
68  return _elgg_services()->metadataTable->delete($this);
69  }
70 
74  public function getObjectFromID($id) {
76  }
77 }
canEdit($user_guid=0)
Determines whether or not the user can edit this piece of metadata.
$user_guid
Definition: login_as.php:10
save()
Save metadata object.
getEntity()
Get the entity this describes.
getObjectFromID($id)
{}
initializeAttributes()
{}
elgg_get_metadata_from_id($id)
Elgg metadata Functions to manage entity metadata.
Definition: metadata.php:16
$value
Definition: generic.php:51
__construct(stdClass $row=null)
Constructor.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
has_access_to_entity(\ElggEntity $entity,\ElggUser $user=null)
Can a user access an entity.
Definition: access.php:95
_elgg_services()
Get the global service provider.
Definition: elgglib.php:777
const ACCESS_PUBLIC
Definition: constants.php:14
$id
Generic annotation delete action.
Definition: delete.php:6