Exemplo n.º 1
0
 public static function getValues($entity_type, $entity, $field_name, $column = NULL)
 {
     if (!empty($entity->{$field_name}) && ($items = field_get_items($entity_type, $entity, $field_name))) {
         if (isset($column)) {
             $value_parents = is_array($column) ? $column : array($column);
             $items = ArrayHelper::extractNestedValuesToArray($items, $value_parents);
         }
         return $items;
     }
     return array();
 }
Exemplo n.º 2
0
 public static function getViewModeOptions($entity_type, $bundle = NULL, $include_disabled = TRUE)
 {
     $view_modes = array();
     $info = entity_get_info($entity_type);
     if (!empty($info['fieldable'])) {
         $view_modes['default'] = t('Default');
     }
     if (!empty($info['view modes'])) {
         $view_modes += ArrayHelper::extractNestedValuesToArray($info['view modes'], array('label'));
     }
     // Filter out disabled view modes if requested, and a bundle was provided.
     if (isset($bundle) && !$include_disabled) {
         $view_mode_settings = field_view_mode_settings($entity_type, $bundle);
         foreach ($view_modes as $view_mode => $label) {
             if (empty($view_mode_settings[$view_mode]['custom_settings'])) {
                 unset($view_modes[$view_mode]);
             }
         }
     }
     return $view_modes;
 }