You are here

class reference_table_formatter_entityreference in Reference Table Formatter 7

Class reference_table_formatter_field_collection

Hierarchy

Expanded class hierarchy of reference_table_formatter_entityreference

1 string reference to 'reference_table_formatter_entityreference'
entityreference.inc in plugins/reference_types/entityreference.inc

File

plugins/reference_types/entityreference.inc, line 15

View source
class reference_table_formatter_entityreference extends reference_table_formatter_base_type {

  /**
   * {@inheritdoc}
   */
  public function get_bundles() {

    // If we are using the base selection, the bundles are easy to find.
    if ($this->field['settings']['handler'] == 'base' && isset($this->field['settings']['handler_settings']['target_bundles']) && count($this->field['settings']['handler_settings']['target_bundles']) > 0) {
      return array_keys($this->field['settings']['handler_settings']['target_bundles']);
    }
    else {

      // Otherwise use all bundles since it's not possible to say for certain
      // which bundles will appear for the field.
      $info = entity_get_info($this
        ->entity_name());
      return array_keys($info['bundles']);
    }
  }

  /**
   * {@inheritdoc}
   */
  public function entity_name() {
    return $this->field['settings']['target_type'];
  }

  /**
   * {@inheritdoc}
   */
  function renderable_properties() {
    $entity_name = $this
      ->entity_name();
    $common_properties = array(
      'node' => array(
        'title',
      ),
      'user' => array(
        'name',
      ),
      'taxonomy_term' => array(
        'name',
      ),
    );
    return isset($common_properties[$entity_name]) ? $common_properties[$entity_name] : array();
  }

  /**
   * {@inheritdoc}
   */
  function load_entity_from_item($item) {
    $loaded_entities = entity_load($this
      ->entity_name(), array(
      $item['target_id'],
    ));
    return array_shift($loaded_entities);
  }

  /**
   * @param $info
   * @return string
   */
  function get_entity_property_label($info) {
    $bundles = $this
      ->get_bundles();

    // It's a unique situation for nodes, to be able to override the label
    // for the "title" property.
    if (count($bundles) == 1 && $this
      ->entity_name() == 'node') {
      $type = node_type_load($bundles[0]);
      return $type->title_label;
    }
    else {
      return parent::get_entity_property_label($info);
    }
  }

}

Members

Namesort descending Modifiers Type Description Overrides
reference_table_formatter_base_type::$field protected property
reference_table_formatter_base_type::$instance protected property
reference_table_formatter_base_type::$settings protected property
reference_table_formatter_base_type::get_bundle_fields function Load all of the fields that can be displayed for a field and instance.
reference_table_formatter_base_type::get_configured_field_list public function The list of fields which will be shown to the user during render.
reference_table_formatter_base_type::get_entity_properties function Get the properties off an entity that are available for rendering.
reference_table_formatter_base_type::get_renderable_fields function Get the fields and properties which can be rendered.
reference_table_formatter_base_type::get_summary public function Get a summary of the configured fields.
reference_table_formatter_base_type::get_view_modes public function Get view modes from the referenced entity.
reference_table_formatter_base_type::hide_empty public function Should empty columns be hidden.
reference_table_formatter_base_type::hide_empty_columns public function Hide columns in a table which are empty.
reference_table_formatter_base_type::is_field public function Check if a key is a property or field.
reference_table_formatter_base_type::render_table public function Render a table of content from the plugin.
reference_table_formatter_base_type::show_all_fields public function Check if the user has left the field checkboxes blank, rendering them all.
reference_table_formatter_base_type::show_header public function Check if the header should be shown on the front-end.
reference_table_formatter_base_type::__construct public function Standard plugin constructor.
reference_table_formatter_entityreference::entity_name public function The entity types that is referenced by the field. Overrides reference_table_formatter_base_type::entity_name
reference_table_formatter_entityreference::get_bundles public function Get a list of bundles which can be referenced by this field. Overrides reference_table_formatter_base_type::get_bundles
reference_table_formatter_entityreference::get_entity_property_label function Overrides reference_table_formatter_base_type::get_entity_property_label
reference_table_formatter_entityreference::load_entity_from_item function Load the target entity from the given item. Overrides reference_table_formatter_base_type::load_entity_from_item
reference_table_formatter_entityreference::renderable_properties function Get a list of properties off the target entity which are renderable. Overrides reference_table_formatter_base_type::renderable_properties