setPrivateSetting() публичный Метод

Private settings are similar to metadata but will not be searched and there are fewer helper functions for them.
public setPrivateSetting ( string $name, mixed $value ) : boolean
$name string Name of private setting
$value mixed Value of private setting
Результат boolean
Пример #1
0
/**
 * Add tags to the sent tags of an entity
 *
 * @param ElggEntity $entity       the entity to add to
 * @param string[]   $sending_tags the newly sent tags
 *
 * @return bool
 */
function tag_tools_add_sent_tags(ElggEntity $entity, $sending_tags = [])
{
    if (!$entity instanceof \ElggEntity) {
        return false;
    }
    if (empty($sending_tags)) {
        // nothing to add
        return true;
    }
    if (!is_array($sending_tags)) {
        $sending_tags = [$sending_tags];
    }
    $sent_tags = $entity->getPrivateSetting('tag_tools:sent_tags');
    if (!empty($sent_tags)) {
        $sent_tags = json_decode($sent_tags, true);
    } else {
        $sent_tags = [];
    }
    // store all processed tags
    $processed_tags = array_merge($sent_tags, $sending_tags);
    $processed_tags = array_unique($processed_tags);
    return $entity->setPrivateSetting('tag_tools:sent_tags', json_encode($processed_tags));
}
Пример #2
0
 /**
  * Handle the update of an ElggEntity
  *
  * @param \ElggEntity $entity the entity
  *
  * @return void
  */
 protected static function updateEntity(\ElggEntity $entity)
 {
     if (!$entity->getPrivateSetting(ELASTICSEARCH_INDEXED_NAME)) {
         return;
     }
     $entity->setPrivateSetting(ELASTICSEARCH_INDEXED_NAME, 0);
 }