You are here

public function EntityMetadataWrapper::optionsList in Entity API 7

Returns the options list specifying possible values for the property, if defined.

Parameters

$op: (optional) One of 'edit' or 'view'. In case the list of possible values a user could set for a property differs from the list of values a property could have, $op determines which options should be returned. Defaults to 'edit'. E.g. all possible roles a user could have include the anonymous and the authenticated user roles, while those roles cannot be added to a user account. So their options would be included for 'view', but for 'edit' not.

Return value

array|false An array as used by hook_options_list() or FALSE.

2 calls to EntityMetadataWrapper::optionsList()
EntityListWrapper::label in includes/entity.wrapper.inc
Returns the label for the list of set values if available.
EntityMetadataWrapper::label in includes/entity.wrapper.inc
Returns the label for the currently set property value if there is one available, i.e. if an options list has been specified.

File

includes/entity.wrapper.inc, line 193
Provides wrappers allowing easy usage of the entity metadata.

Class

EntityMetadataWrapper
A common base class for all wrappers.

Code

public function optionsList($op = 'edit') {
  if (isset($this->info['options list']) && is_callable($this->info['options list'])) {
    $name = isset($this->info['name']) ? $this->info['name'] : NULL;
    return call_user_func($this->info['options list'], $name, $this->info, $op);
  }
  return FALSE;
}