You are here

public function SearchApiEntityDataSourceController::getItemUrl in Search API 7

Retrieves a URL at which the item can be viewed on the web.

Parameters

mixed $item: An item of this controller's type.

Return value

array|null Either an array containing the 'path' and 'options' keys used to build the URL of the item, and matching the signature of url(), or NULL if the item has no URL of its own.

Throws

SearchApiDataSourceException If any error state was encountered.

Overrides SearchApiAbstractDataSourceController::getItemUrl

File

includes/datasource_entity.inc, line 122
Contains the SearchApiEntityDataSourceController class.

Class

SearchApiEntityDataSourceController
Represents a datasource for all entities known to the Entity API.

Code

public function getItemUrl($item) {
  if ($this->entityType == 'file') {
    return array(
      'path' => file_create_url($item->uri),
      'options' => array(
        'entity_type' => 'file',
        'entity' => $item,
      ),
    );
  }
  $url = entity_uri($this->entityType, $item);
  return $url ? $url : NULL;
}