18 protected array $temp_metadata = [];
39 return array_map(
function($values) {
40 return count($values) > 1 ? $values : $values[0];
41 }, $this->temp_metadata);
45 if ($metadata === null) {
49 if (empty($metadata)) {
53 $metadata_values = [];
54 foreach ($metadata as $md) {
55 $metadata_values[$md->name][] = $md->value;
58 return array_map(
function($values) {
59 return count($values) > 1 ? $values : $values[0];
79 if ($value === null || $value ===
'') {
85 if (is_array($value)) {
86 $value = array_values($value);
92 $value = array_filter($value,
function($var) {
93 return !is_null($var);
96 if (empty($this->guid)) {
105 if ((is_array($current_metadata) ||
count($value) > 1 || $value === []) && isset($current_metadata)) {
111 'guid' => $this->guid,
112 'metadata_name' => $name,
117 if ($delete_result ===
false) {
122 if (
count($value) > 1) {
129 foreach ($value as $value_tmp) {
135 if (!empty($value_type)) {
140 if ($md_id ===
false) {
161 unset($this->temp_metadata[$name]);
170 if (!isset($this->temp_metadata[$name])) {
171 $this->temp_metadata[
$name] = [];
174 $this->temp_metadata[
$name] = array_merge($this->temp_metadata[$name], $value);
194 if (isset($this->temp_metadata[
$name])) {
195 unset($this->temp_metadata[$name]);
198 $this->temp_metadata = [];
205 'guid' => $this->guid,
207 'metadata_name' =>
$name,
elgg_call(int $flags, Closure $closure)
Calls a callable autowiring the arguments using public DI services and applying logic based on flags...
if(!$user||!$user->canDelete()) $name
deleteMetadata(string $name=null)
Deletes all metadata on this object (metadata.entity_guid = $this->guid).
getAllMetadata()
Get all entity metadata.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
const ELGG_IGNORE_ACCESS
elgg_call() flags
setTempMetadata(string $name, mixed $value, bool $multiple=false)
Set temp metadata on this entity.
setMetadata(string $name, mixed $value, string $value_type= '', bool $multiple=false)
Set metadata on this entity.
_elgg_services()
Get the global service provider.
getMetadata(string $name)
Return the value of a piece of metadata.
$guid
Reset an ElggUpgrade.