13 use Elgg\Traits\TimeUsing;
68 $singulars = [
'tag_name'];
81 return "{$main_alias}.value AS tag";
84 return "COUNT({$main_alias}.id) AS total";
101 return "{$main_alias}.value";
118 $options[
'callback'] =
function($row) {
121 $result->total = (int) $row->total;
142 $qb->addClause(MetadataWhereClause::factory([
'ids' =>
$id]));
144 $row = $this->db->getDataRow(
$qb);
145 return $row ? new \ElggMetadata($row) :
null;
160 if (!$this->events->trigger(
'delete',
'metadata',
$metadata)) {
170 $metadata->getEntity()?->invalidateCache();
190 elgg_log(
'Metadata must have a value and entity guid', \Psr\Log\LogLevel::ERROR);
194 if (!$this->entityTable->exists(
$metadata->entity_guid)) {
195 elgg_log(
"Can't create metadata on a non-existing entity_guid", \Psr\Log\LogLevel::ERROR);
200 elgg_log(
'To set multiple metadata values use ElggEntity::setMetadata', \Psr\Log\LogLevel::ERROR);
210 if (!$allow_multiple) {
214 throw new LogicException(
"
215 Multiple '{$metadata->name}' metadata values exist for entity [guid: {$metadata->entity_guid}].
216 Use ElggEntity::setMetadata()
229 if (!$this->events->triggerBefore(
'create',
'metadata',
$metadata)) {
244 $id = $this->db->insertData(
$qb);
253 if (!$this->events->trigger(
'create',
'metadata',
$metadata)) {
259 $metadata->getEntity()?->invalidateCache();
261 $this->events->triggerAfter(
'create',
'metadata',
$metadata);
274 if (!$this->entityTable->exists(
$metadata->entity_guid)) {
275 elgg_log(
"Can't update metadata to a non-existing entity_guid", \Psr\Log\LogLevel::ERROR);
279 if (!$this->events->triggerBefore(
'update',
'metadata',
$metadata)) {
295 $metadata->getEntity()?->invalidateCache();
297 $this->events->trigger(
'update',
'metadata',
$metadata);
298 $this->events->triggerAfter(
'update',
'metadata',
$metadata);
330 $qb =
Select::fromTable(self::TABLE_NAME);
333 ->orderBy(
'entity_guid',
'asc')
334 ->addOrderBy(
'time_created',
'asc')
335 ->addOrderBy(
'id',
'asc');
337 return $this->db->getData(
$qb,
function ($row) {
338 return new \ElggMetadata($row);
360 'metadata_name',
'metadata_names',
361 'metadata_value',
'metadata_values',
381 $this->access_cache->clear();
382 $this->metadata_cache->clear();
384 $this->entityTable->invalidateCache(
$options[
'guid']);
389 $options[
'batch_inc_offset'] =
false;
406 return $success ===
$count;
418 $cached_metadata = $this->metadata_cache->load(
$entity_guid);
419 if ($cached_metadata !==
null) {
421 foreach ($cached_metadata as $md) {
422 if ($md->name !==
$name) {
429 $qb = Select::fromTable(self::TABLE_NAME);
434 $callback =
function (\stdClass $row) {
435 return (
int) $row->id;
438 $ids = $this->db->getData(
$qb, $callback);
445 if (is_array($ids) && count($ids) === 1) {
446 return array_shift($ids);
getCurrentTime($modifier='')
Get the (cloned) time.
if(! $user||! $user->canDelete()) $name
$id
Generic annotation delete action.
$guids
Activates all specified installed and inactive plugins.
Extends QueryBuilder with ORDER BY clauses.
static fromTable(string $table)
Returns a QueryBuilder for deleting data from a given table.
Entity table database service.
static intoTable(string $table)
Returns a QueryBuilder for inserting data in a given table.
Database abstraction query builder.
Query builder for fetching data from the database.
static fromTable(string $table, ?string $alias=null)
Returns a QueryBuilder for selecting data from a given table.
static table(string $table)
Returns a QueryBuilder for updating data in a given table.
Exception thrown if an argument is not of the expected type.
Exception that represents error in the program logic.
const ELGG_VALUE_INTEGER
Value types.
if($who_can_change_language==='nobody') elseif($who_can_change_language==='admin_only' &&!elgg_is_admin_logged_in()) $options
if(! $user instanceof \ElggUser) $time_created
foreach($recommendedExtensions as $extension) if(empty(ini_get('session.gc_probability'))||empty(ini_get('session.gc_divisor'))) $db
elgg_log($message, $level=\Psr\Log\LogLevel::NOTICE)
Log a message.
elgg_extract($key, $array, $default=null, bool $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
if($container instanceof ElggGroup && $container->guid !=elgg_get_page_owner_guid()) $key
if(parse_url(elgg_get_site_url(), PHP_URL_PATH) !=='/') if(file_exists(elgg_get_root_path() . 'robots.txt'))
Set robots.txt.