You are here

abstract class _entityreference_CrumbsMultiPlugin in Crumbs, the Breadcrumbs suite 7

Hierarchy

Expanded class hierarchy of _entityreference_CrumbsMultiPlugin

File

plugins/crumbs.entityreference.inc, line 23

View source
abstract class _entityreference_CrumbsMultiPlugin implements crumbs_MultiPlugin {
  protected $fieldKey;
  protected $bundles;

  // To be defined by the child class
  protected $entityType;
  function __construct($field_key, $bundles) {
    $this->fieldKey = $field_key;
    $this->bundles = $bundles;
  }
  function describe($api) {
    foreach ($this->bundles as $bundle) {
      $api
        ->addRule($bundle, $bundle);
    }
  }
  protected function _findParentPath($entity) {
    $items = field_get_items($this->entityType, $entity, $this->fieldKey);
    if ($items) {
      $field = field_info_field($this->fieldKey);
      $item = $items[0];
      $target_id = $item['target_id'];
      $target_type = $field['settings']['target_type'];
      $method = '_getPath_' . $target_type;
      if (method_exists($this, $method)) {
        return $this
          ->{$method}($target_id);
      }
    }
  }
  protected function _getPath_node($nid) {
    return 'node/' . $nid;
  }
  protected function _getPath_user($uid) {
    return 'user/' . $uid;
  }

}

Members