Files
core/include/observer.php
Harald Eilertsen e70870ce4e Move observer helper functions to separate source
The main goal was to move the functions out of the already overcrowded
`boot.php`. While I would ideally have liked to move them properly under
a namespace under `Zotlabs\`, that would break too much existing code at
this point.

Thus leaving it in include and under the global namespace for now.
2025-05-09 15:20:38 +02:00

61 lines
1.2 KiB
PHP

<?php
/**
* Helper functions for getting info about the observer.
*
* SPDX-FileCopyrightText: 2025 The Hubzilla Community
* SPDX-FileContributor: Harald Eilertsen <haraldei@anduin.net>
*
* SPDX-License-Identifier: MIT
*/
/**
* Get the unique hash identifying the current observer.
*
* Observer can be a local or remote channel.
*
* @return string Unique hash of observer, otherwise empty string if no
* observer
*/
function get_observer_hash() {
$observer = App::get_observer();
if (is_array($observer)) {
return $observer['xchan_hash'];
}
return '';
}
/**
* Get the guid of the current observer.
*
* Observer can be a local or remote channel.
*
* @return string The GUID of the observer, otherwise empty string if no
* observer
*/
function get_observer_guid() {
$observer = App::get_observer();
if (is_array($observer)) {
return $observer['xchan_guid'];
}
return '';
}
/**
* Get the name of the current observer.
*
* Observer can be a local or remote channel.
*
* @return string The name of the observer, otherwise empty string if no
* observer
*/
function get_observer_name() {
$observer = App::get_observer();
if (is_array($observer)) {
return $observer['xchan_name'];
}
return '';
}