Elgg  Version 6.1
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(int $user_guid = 0): bool {
46  return elgg_has_access_to_entity($this->entity_guid, $user_guid);
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(): bool {
68  return _elgg_services()->metadataTable->delete($this);
69  }
70 
74  public function getObjectFromID(int $id) {
75  return elgg_get_metadata_from_id($id);
76  }
77 }
$user_guid
Definition: login_as.php:10
save()
Save metadata object.
elgg_get_metadata_from_id(int $id)
Elgg metadata Functions to manage entity metadata.
Definition: metadata.php:16
initializeAttributes()
{}
$value
Definition: generic.php:51
getObjectFromID(int $id)
{}
elgg_has_access_to_entity(int $entity_guid, int $user_guid=0)
Can a user access an entity.
Definition: access.php:91
__construct(stdClass $row=null)
Constructor.
ElggMetadata.
canEdit(int $user_guid=0)
Determines whether or not the user can edit this piece of metadata.
if($container instanceof ElggGroup &&$container->guid!=elgg_get_page_owner_guid()) $key
Definition: summary.php:44
_elgg_services()
Get the global service provider.
Definition: elgglib.php:353
const ACCESS_PUBLIC
Definition: constants.php:12
$id
Generic annotation delete action.
Definition: delete.php:6