You are here

function entityreference_prepopulate_CrumbsMonoPlugin_node::findParent in Crumbs, the Breadcrumbs suite 7.2

Find candidates for the parent path.

Parameters

string $path: The path that we want to find a parent for.

array $item: Item as returned from crumbs_get_router_item()

Return value

string Parent path candidate.

Overrides crumbs_MonoPlugin_FindParentInterface::findParent

File

plugins/crumbs.entityreference_prepopulate.inc, line 80

Class

entityreference_prepopulate_CrumbsMonoPlugin_node

Code

function findParent($path, $item) {
  if (empty($_GET[$this->fieldName])) {
    return NULL;
  }
  $v = $_GET[$this->fieldName];
  if (!($v > 0)) {
    return NULL;
  }
  $target_entities = entity_load($this->targetType, array(
    $v,
  ));
  if (empty($target_entities[$v])) {
    return NULL;
  }
  $uri = entity_uri($this->targetType, $target_entities[$v]);
  if (empty($uri['path'])) {
    return NULL;
  }
  return $uri['path'];
}