You are here

function hook_farm_info in farmOS 7

Provide general information about this farmOS system.

Return value

array Returns an array of farm information.

Related topics

7 functions implement hook_farm_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

farm_api_farm_info in modules/farm/farm_api/farm_api.module
Implements hook_farm_api_farm_info().
farm_client_farm_info in modules/farm/farm_client/farm_client.module
Implements hook_farm_info().
farm_map_google_farm_info in modules/farm/farm_map/farm_map_google/farm_map_google.module
Implements hook_farm_info().
farm_map_mapbox_farm_info in modules/farm/farm_map/farm_map_mapbox/farm_map_mapbox.module
Implements hook_farm_info().
farm_metrics_farm_info in modules/farm/farm_metrics/farm_metrics.module
Implements hook_farm_info().

... See full list

File

modules/farm/farm_api/farm_api.api.php, line 30
Hooks provided by farm_api.

Code

function hook_farm_info() {
  global $base_url, $conf, $user;

  // Info items can be added simply:
  $info = array(
    'name' => $conf['site_name'],
    'url' => $base_url,
  );

  // Or an entire array of info can be added simply:
  if (!empty($user->uid)) {
    $info['user'] = array(
      'uid' => $user->uid,
      'name' => $user->name,
      'mail' => $user->mail,
    );
  }

  // Or, they can be arrays with 'info' and 'scope' keys. The 'info' is what
  // will be included in the farmOS API info array. The 'scope' is an OAuth2
  // scope that will be checked for access. This scope must be defined in
  // the farmos_api_client OAuth2 Server. This allows some information to be
  // available to OAuth2-authenticated services without a full user log in.
  $info['foo'] = array(
    'info' => 'bar',
    'scope' => 'access_foo',
  );
  return $info;
}