|
@@ -12,45 +12,55 @@
|
|
* They are used for loading items, extracting item data, keeping track of the
|
|
* They are used for loading items, extracting item data, keeping track of the
|
|
* item status, etc.
|
|
* item status, etc.
|
|
*
|
|
*
|
|
- * All methods of the data source may throw exceptions of type
|
|
+ * Modules providing implementations of this interface that use a different way
|
|
- * SearchApiDataSourceException if any exception or error state is encountered.
|
|
+ * (either different table or different method altogether) of keeping track of
|
|
|
|
+ * indexed/dirty items than SearchApiAbstractDataSourceController should be
|
|
|
|
+ * aware that indexes' numerical IDs can change due to feature reverts. It is
|
|
|
|
+ * therefore recommended to use search_api_index_update_datasource(), or similar
|
|
|
|
+ * code, in a hook_search_api_index_update() implementation.
|
|
*/
|
|
*/
|
|
interface SearchApiDataSourceControllerInterface {
|
|
interface SearchApiDataSourceControllerInterface {
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Constructor for a data source controller.
|
|
+ * Constructs an SearchApiDataSourceControllerInterface object.
|
|
*
|
|
*
|
|
- * @param $type
|
|
+ * @param string $type
|
|
* The item type for which this controller is created.
|
|
* The item type for which this controller is created.
|
|
*/
|
|
*/
|
|
public function __construct($type);
|
|
public function __construct($type);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Return information on the ID field for this controller's type.
|
|
+ * Returns information on the ID field for this controller's type.
|
|
*
|
|
*
|
|
* @return array
|
|
* @return array
|
|
* An associative array containing the following keys:
|
|
* An associative array containing the following keys:
|
|
* - key: The property key for the ID field, as used in the item wrapper.
|
|
* - key: The property key for the ID field, as used in the item wrapper.
|
|
* - type: The type of the ID field. Has to be one of the types from
|
|
* - type: The type of the ID field. Has to be one of the types from
|
|
* search_api_field_types(). List types ("list<*>") are not allowed.
|
|
* search_api_field_types(). List types ("list<*>") are not allowed.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getIdFieldInfo();
|
|
public function getIdFieldInfo();
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Load items of the type of this data source controller.
|
|
+ * Loads items of the type of this data source controller.
|
|
*
|
|
*
|
|
* @param array $ids
|
|
* @param array $ids
|
|
- * The IDs of the items to laod.
|
|
+ * The IDs of the items to load.
|
|
*
|
|
*
|
|
* @return array
|
|
* @return array
|
|
* The loaded items, keyed by ID.
|
|
* The loaded items, keyed by ID.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function loadItems(array $ids);
|
|
public function loadItems(array $ids);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a metadata wrapper for the item type of this data source controller.
|
|
+ * Creates a metadata wrapper for this datasource controller's type.
|
|
*
|
|
*
|
|
- * @param $item
|
|
+ * @param mixed $item
|
|
* Unless NULL, an item of the item type for this controller to be wrapped.
|
|
* Unless NULL, an item of the item type for this controller to be wrapped.
|
|
* @param array $info
|
|
* @param array $info
|
|
* Optionally, additional information that should be used for creating the
|
|
* Optionally, additional information that should be used for creating the
|
|
@@ -60,151 +70,182 @@ interface SearchApiDataSourceControllerInterface {
|
|
* A wrapper for the item type of this data source controller, according to
|
|
* A wrapper for the item type of this data source controller, according to
|
|
* the info array, and optionally loaded with the given data.
|
|
* the info array, and optionally loaded with the given data.
|
|
*
|
|
*
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
|
|
+ *
|
|
* @see entity_metadata_wrapper()
|
|
* @see entity_metadata_wrapper()
|
|
*/
|
|
*/
|
|
public function getMetadataWrapper($item = NULL, array $info = array());
|
|
public function getMetadataWrapper($item = NULL, array $info = array());
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the unique ID of an item.
|
|
+ * Retrieves the unique ID of an item.
|
|
*
|
|
*
|
|
- * @param $item
|
|
+ * @param mixed $item
|
|
* An item of this controller's type.
|
|
* An item of this controller's type.
|
|
*
|
|
*
|
|
- * @return
|
|
+ * @return mixed
|
|
* Either the unique ID of the item, or NULL if none is available.
|
|
* Either the unique ID of the item, or NULL if none is available.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getItemId($item);
|
|
public function getItemId($item);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a human-readable label for an item.
|
|
+ * Retrieves a human-readable label for an item.
|
|
*
|
|
*
|
|
- * @param $item
|
|
+ * @param mixed $item
|
|
* An item of this controller's type.
|
|
* An item of this controller's type.
|
|
*
|
|
*
|
|
- * @return
|
|
+ * @return string|null
|
|
* Either a human-readable label for the item, or NULL if none is available.
|
|
* Either a human-readable label for the item, or NULL if none is available.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getItemLabel($item);
|
|
public function getItemLabel($item);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a URL at which the item can be viewed on the web.
|
|
+ * Retrieves a URL at which the item can be viewed on the web.
|
|
*
|
|
*
|
|
- * @param $item
|
|
+ * @param mixed $item
|
|
* An item of this controller's type.
|
|
* An item of this controller's type.
|
|
*
|
|
*
|
|
- * @return
|
|
+ * @return array|null
|
|
* Either an array containing the 'path' and 'options' keys used to build
|
|
* 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
|
|
* the URL of the item, and matching the signature of url(), or NULL if the
|
|
* item has no URL of its own.
|
|
* item has no URL of its own.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getItemUrl($item);
|
|
public function getItemUrl($item);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Initialize tracking of the index status of items for the given indexes.
|
|
+ * Initializes tracking of the index status of items for the given indexes.
|
|
*
|
|
*
|
|
* All currently known items of this data source's type should be inserted
|
|
* All currently known items of this data source's type should be inserted
|
|
* into the tracking table for the given indexes, with status "changed". If
|
|
* into the tracking table for the given indexes, with status "changed". If
|
|
* items were already present, these should also be set to "changed" and not
|
|
* items were already present, these should also be set to "changed" and not
|
|
* be inserted again.
|
|
* be inserted again.
|
|
*
|
|
*
|
|
- * @param array $indexes
|
|
+ * @param SearchApiIndex[] $indexes
|
|
* The SearchApiIndex objects for which item tracking should be initialized.
|
|
* The SearchApiIndex objects for which item tracking should be initialized.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function startTracking(array $indexes);
|
|
public function startTracking(array $indexes);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Stop tracking of the index status of items for the given indexes.
|
|
+ * Stops tracking of the index status of items for the given indexes.
|
|
*
|
|
*
|
|
* The tracking tables of the given indexes should be completely cleared.
|
|
* The tracking tables of the given indexes should be completely cleared.
|
|
*
|
|
*
|
|
- * @param array $indexes
|
|
+ * @param SearchApiIndex[] $indexes
|
|
* The SearchApiIndex objects for which item tracking should be stopped.
|
|
* The SearchApiIndex objects for which item tracking should be stopped.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function stopTracking(array $indexes);
|
|
public function stopTracking(array $indexes);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Start tracking the index status for the given items on the given indexes.
|
|
+ * Starts tracking the index status for the given items on the given indexes.
|
|
*
|
|
*
|
|
* @param array $item_ids
|
|
* @param array $item_ids
|
|
* The IDs of new items to track.
|
|
* The IDs of new items to track.
|
|
- * @param array $indexes
|
|
+ * @param SearchApiIndex[] $indexes
|
|
* The indexes for which items should be tracked.
|
|
* The indexes for which items should be tracked.
|
|
*
|
|
*
|
|
|
|
+ * @return SearchApiIndex[]|null
|
|
|
|
+ * All indexes for which any items were added; or NULL if items were added
|
|
|
|
+ * for all of them.
|
|
|
|
+ *
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function trackItemInsert(array $item_ids, array $indexes);
|
|
public function trackItemInsert(array $item_ids, array $indexes);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "changed"/"dirty".
|
|
+ * Sets the tracking status of the given items to "changed"/"dirty".
|
|
*
|
|
*
|
|
* Unless $dequeue is set to TRUE, this operation is ignored for items whose
|
|
* Unless $dequeue is set to TRUE, this operation is ignored for items whose
|
|
* status is not "indexed".
|
|
* status is not "indexed".
|
|
*
|
|
*
|
|
- * @param $item_ids
|
|
+ * @param array|false $item_ids
|
|
* Either an array with the IDs of the changed items. Or FALSE to mark all
|
|
* Either an array with the IDs of the changed items. Or FALSE to mark all
|
|
* items as changed for the given indexes.
|
|
* items as changed for the given indexes.
|
|
- * @param array $indexes
|
|
+ * @param SearchApiIndex[] $indexes
|
|
* The indexes for which the change should be tracked.
|
|
* The indexes for which the change should be tracked.
|
|
- * @param $dequeue
|
|
+ * @param bool $dequeue
|
|
- * If set to TRUE, also change the status of queued items.
|
|
+ * (deprecated) If set to TRUE, also change the status of queued items.
|
|
|
|
+ * The concept of queued items will be removed in the Drupal 8 version of
|
|
|
|
+ * this module.
|
|
|
|
+ *
|
|
|
|
+ * @return SearchApiIndex[]|null
|
|
|
|
+ * All indexes for which any items were updated; or NULL if items were
|
|
|
|
+ * updated for all of them.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function trackItemChange($item_ids, array $indexes, $dequeue = FALSE);
|
|
public function trackItemChange($item_ids, array $indexes, $dequeue = FALSE);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "queued".
|
|
+ * Sets the tracking status of the given items to "queued".
|
|
*
|
|
*
|
|
* Queued items are not marked as "dirty" even when they are changed, and they
|
|
* Queued items are not marked as "dirty" even when they are changed, and they
|
|
* are not returned by the getChangedItems() method.
|
|
* are not returned by the getChangedItems() method.
|
|
*
|
|
*
|
|
- * @param $item_ids
|
|
+ * @param array|false $item_ids
|
|
* Either an array with the IDs of the queued items. Or FALSE to mark all
|
|
* Either an array with the IDs of the queued items. Or FALSE to mark all
|
|
* items as queued for the given indexes.
|
|
* items as queued for the given indexes.
|
|
* @param SearchApiIndex $index
|
|
* @param SearchApiIndex $index
|
|
* The index for which the items were queued.
|
|
* The index for which the items were queued.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
|
|
+ *
|
|
|
|
+ * @deprecated
|
|
|
|
+ * As of Search API 1.10, the cron queue is not used for indexing anymore,
|
|
|
|
+ * therefore this method has become useless. It will be removed in the
|
|
|
|
+ * Drupal 8 version of this module.
|
|
*/
|
|
*/
|
|
public function trackItemQueued($item_ids, SearchApiIndex $index);
|
|
public function trackItemQueued($item_ids, SearchApiIndex $index);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "indexed".
|
|
+ * Sets the tracking status of the given items to "indexed".
|
|
*
|
|
*
|
|
* @param array $item_ids
|
|
* @param array $item_ids
|
|
* The IDs of the indexed items.
|
|
* The IDs of the indexed items.
|
|
- * @param SearchApiIndex $indexes
|
|
+ * @param SearchApiIndex $index
|
|
* The index on which the items were indexed.
|
|
* The index on which the items were indexed.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If the index doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function trackItemIndexed(array $item_ids, SearchApiIndex $index);
|
|
public function trackItemIndexed(array $item_ids, SearchApiIndex $index);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Stop tracking the index status for the given items on the given indexes.
|
|
+ * Stops tracking the index status for the given items on the given indexes.
|
|
*
|
|
*
|
|
* @param array $item_ids
|
|
* @param array $item_ids
|
|
* The IDs of the removed items.
|
|
* The IDs of the removed items.
|
|
- * @param array $indexes
|
|
+ * @param SearchApiIndex[] $indexes
|
|
* The indexes for which the deletions should be tracked.
|
|
* The indexes for which the deletions should be tracked.
|
|
*
|
|
*
|
|
|
|
+ * @return SearchApiIndex[]|null
|
|
|
|
+ * All indexes for which any items were deleted; or NULL if items were
|
|
|
|
+ * deleted for all of them.
|
|
|
|
+ *
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function trackItemDelete(array $item_ids, array $indexes);
|
|
public function trackItemDelete(array $item_ids, array $indexes);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a list of items that need to be indexed.
|
|
+ * Retrieves a list of items that need to be indexed.
|
|
*
|
|
*
|
|
* If possible, completely unindexed items should be returned before items
|
|
* If possible, completely unindexed items should be returned before items
|
|
* that were indexed but later changed. Also, items that were changed longer
|
|
* that were indexed but later changed. Also, items that were changed longer
|
|
@@ -212,16 +253,19 @@ interface SearchApiDataSourceControllerInterface {
|
|
*
|
|
*
|
|
* @param SearchApiIndex $index
|
|
* @param SearchApiIndex $index
|
|
* The index for which changed items should be returned.
|
|
* The index for which changed items should be returned.
|
|
- * @param $limit
|
|
+ * @param int $limit
|
|
* The maximum number of items to return. Negative values mean "unlimited".
|
|
* The maximum number of items to return. Negative values mean "unlimited".
|
|
*
|
|
*
|
|
* @return array
|
|
* @return array
|
|
* The IDs of items that need to be indexed for the given index.
|
|
* The IDs of items that need to be indexed for the given index.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getChangedItems(SearchApiIndex $index, $limit = -1);
|
|
public function getChangedItems(SearchApiIndex $index, $limit = -1);
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get information on how many items have been indexed for a certain index.
|
|
+ * Retrieves information on how many items have been indexed for a certain index.
|
|
*
|
|
*
|
|
* @param SearchApiIndex $index
|
|
* @param SearchApiIndex $index
|
|
* The index whose index status should be returned.
|
|
* The index whose index status should be returned.
|
|
@@ -233,14 +277,89 @@ interface SearchApiDataSourceControllerInterface {
|
|
* index.
|
|
* index.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If the index doesn't use the same item type as this controller.
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
public function getIndexStatus(SearchApiIndex $index);
|
|
public function getIndexStatus(SearchApiIndex $index);
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * Retrieves the entity type of items from this datasource.
|
|
|
|
+ *
|
|
|
|
+ * @return string|null
|
|
|
|
+ * An entity type string if the items provided by this datasource are
|
|
|
|
+ * entities; NULL otherwise.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
|
|
+ */
|
|
|
|
+ public function getEntityType();
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Form constructor for configuring the datasource for a given index.
|
|
|
|
+ *
|
|
|
|
+ * @param array $form
|
|
|
|
+ * The form returned by configurationForm().
|
|
|
|
+ * @param array $form_state
|
|
|
|
+ * The form state. $form_state['index'] will contain the edited index. If
|
|
|
|
+ * this key is empty, then a new index is being created. In case of an edit,
|
|
|
|
+ * $form_state['index']->options['datasource'] contains the previous
|
|
|
|
+ * settings for the datasource.
|
|
|
|
+ *
|
|
|
|
+ * @return array|false
|
|
|
|
+ * A form array for configuring this callback, or FALSE if no configuration
|
|
|
|
+ * is possible.
|
|
|
|
+ */
|
|
|
|
+ public function configurationForm(array $form, array &$form_state);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Validation callback for the form returned by configurationForm().
|
|
|
|
+ *
|
|
|
|
+ * This method will only be called if that form was non-empty.
|
|
|
|
+ *
|
|
|
|
+ * @param array $form
|
|
|
|
+ * The form returned by configurationForm().
|
|
|
|
+ * @param array $values
|
|
|
|
+ * The part of the $form_state['values'] array corresponding to this form.
|
|
|
|
+ * @param array $form_state
|
|
|
|
+ * The complete form state.
|
|
|
|
+ */
|
|
|
|
+ public function configurationFormValidate(array $form, array &$values, array &$form_state);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Submit callback for the form returned by configurationForm().
|
|
|
|
+ *
|
|
|
|
+ * This method will only be called if that form was non-empty.
|
|
|
|
+ *
|
|
|
|
+ * Any necessary changes to the submitted values should be made, afterwards
|
|
|
|
+ * they will automatically be stored as the index's "datasource" options. The
|
|
|
|
+ * method can also be used by the datasource controller to react to the
|
|
|
|
+ * possible change in its settings.
|
|
|
|
+ *
|
|
|
|
+ * @param array $form
|
|
|
|
+ * The form returned by configurationForm().
|
|
|
|
+ * @param array $values
|
|
|
|
+ * The part of the $form_state['values'] array corresponding to this form.
|
|
|
|
+ * @param array $form_state
|
|
|
|
+ * The complete form state.
|
|
|
|
+ */
|
|
|
|
+ public function configurationFormSubmit(array $form, array &$values, array &$form_state);
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Returns a summary of an index's current datasource configuration.
|
|
|
|
+ *
|
|
|
|
+ * @param SearchApiIndex $index
|
|
|
|
+ * The index whose datasource configuration should be summarized.
|
|
|
|
+ *
|
|
|
|
+ * @return string|null
|
|
|
|
+ * A translated string describing the index's current datasource
|
|
|
|
+ * configuration. Or NULL, if there is no configuration (or no description
|
|
|
|
+ * is available).
|
|
|
|
+ */
|
|
|
|
+ public function getConfigurationSummary(SearchApiIndex $index);
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Default base class for the SearchApiDataSourceControllerInterface.
|
|
+ * Provides a default base class for datasource controllers.
|
|
*
|
|
*
|
|
* Contains default implementations for a number of methods which will be
|
|
* Contains default implementations for a number of methods which will be
|
|
* similar for most data sources. Concrete data sources can decide to extend
|
|
* similar for most data sources. Concrete data sources can decide to extend
|
|
@@ -264,6 +383,15 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
*/
|
|
*/
|
|
protected $type;
|
|
protected $type;
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
+ * The entity type for this controller instance.
|
|
|
|
+ *
|
|
|
|
+ * @var string|null
|
|
|
|
+ *
|
|
|
|
+ * @see getEntityType()
|
|
|
|
+ */
|
|
|
|
+ protected $entityType = NULL;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* The info array for the item type, as specified via
|
|
* The info array for the item type, as specified via
|
|
* hook_search_api_item_type_info().
|
|
* hook_search_api_item_type_info().
|
|
@@ -306,57 +434,86 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
protected $changedColumn = 'changed';
|
|
protected $changedColumn = 'changed';
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Constructor for a data source controller.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param $type
|
|
|
|
- * The item type for which this controller is created.
|
|
|
|
*/
|
|
*/
|
|
public function __construct($type) {
|
|
public function __construct($type) {
|
|
$this->type = $type;
|
|
$this->type = $type;
|
|
$this->info = search_api_get_item_type_info($type);
|
|
$this->info = search_api_get_item_type_info($type);
|
|
|
|
+
|
|
|
|
+ if (!empty($this->info['entity_type'])) {
|
|
|
|
+ $this->entityType = $this->info['entity_type'];
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a metadata wrapper for the item type of this data source controller.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
+ */
|
|
- * @param $item
|
|
+ public function getEntityType() {
|
|
- * Unless NULL, an item of the item type for this controller to be wrapped.
|
|
+ return $this->entityType;
|
|
- * @param array $info
|
|
+ }
|
|
- * Optionally, additional information that should be used for creating the
|
|
+
|
|
- * wrapper. Uses the same format as entity_metadata_wrapper().
|
|
+ /**
|
|
- *
|
|
+ * {@inheritdoc}
|
|
- * @return EntityMetadataWrapper
|
|
|
|
- * A wrapper for the item type of this data source controller, according to
|
|
|
|
- * the info array, and optionally loaded with the given data.
|
|
|
|
- *
|
|
|
|
- * @see entity_metadata_wrapper()
|
|
|
|
*/
|
|
*/
|
|
public function getMetadataWrapper($item = NULL, array $info = array()) {
|
|
public function getMetadataWrapper($item = NULL, array $info = array()) {
|
|
$info += $this->getPropertyInfo();
|
|
$info += $this->getPropertyInfo();
|
|
- return entity_metadata_wrapper($this->type, $item, $info);
|
|
+ return entity_metadata_wrapper($this->entityType ? $this->entityType : $this->type, $item, $info);
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Helper method that can be used by subclasses to specify the property
|
|
+ * Retrieves the property info for this item type.
|
|
- * information to use when creating a metadata wrapper.
|
|
+ *
|
|
|
|
+ * This is a helper method for getMetadataWrapper() that can be used by
|
|
|
|
+ * subclasses to specify the property information to use when creating a
|
|
|
|
+ * metadata wrapper.
|
|
|
|
+ *
|
|
|
|
+ * The data structure uses largely the format specified in
|
|
|
|
+ * hook_entity_property_info(). However, the first level of keys (containing
|
|
|
|
+ * the entity types) is omitted, and the "properties" key is called
|
|
|
|
+ * "property info" instead. So, an example return value would look like this:
|
|
|
|
+ *
|
|
|
|
+ * @code
|
|
|
|
+ * return array(
|
|
|
|
+ * 'property info' => array(
|
|
|
|
+ * 'foo' => array(
|
|
|
|
+ * 'label' => t('Foo'),
|
|
|
|
+ * 'type' => 'text',
|
|
|
|
+ * ),
|
|
|
|
+ * 'bar' => array(
|
|
|
|
+ * 'label' => t('Bar'),
|
|
|
|
+ * 'type' => 'list<integer>',
|
|
|
|
+ * ),
|
|
|
|
+ * ),
|
|
|
|
+ * );
|
|
|
|
+ * @endcode
|
|
|
|
+ *
|
|
|
|
+ * SearchApiExternalDataSourceController::getPropertyInfo() contains a working
|
|
|
|
+ * example of this method.
|
|
|
|
+ *
|
|
|
|
+ * If the item type is an entity type, no additional property information is
|
|
|
|
+ * required, the method will thus just return an empty array. You can still
|
|
|
|
+ * use this to append additional properties to the entities, or the like,
|
|
|
|
+ * though.
|
|
*
|
|
*
|
|
* @return array
|
|
* @return array
|
|
- * Property information as specified by hook_entity_property_info().
|
|
+ * Property information as specified by entity_metadata_wrapper().
|
|
*
|
|
*
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
|
|
+ *
|
|
|
|
+ * @see getMetadataWrapper()
|
|
* @see hook_entity_property_info()
|
|
* @see hook_entity_property_info()
|
|
*/
|
|
*/
|
|
protected function getPropertyInfo() {
|
|
protected function getPropertyInfo() {
|
|
|
|
+ // If this is an entity type, no additional property info is needed.
|
|
|
|
+ if ($this->entityType) {
|
|
|
|
+ return array();
|
|
|
|
+ }
|
|
throw new SearchApiDataSourceException(t('No known property information for type @type.', array('@type' => $this->type)));
|
|
throw new SearchApiDataSourceException(t('No known property information for type @type.', array('@type' => $this->type)));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get the unique ID of an item.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param $item
|
|
|
|
- * An item of this controller's type.
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- * Either the unique ID of the item, or NULL if none is available.
|
|
|
|
*/
|
|
*/
|
|
public function getItemId($item) {
|
|
public function getItemId($item) {
|
|
$id_info = $this->getIdFieldInfo();
|
|
$id_info = $this->getIdFieldInfo();
|
|
@@ -370,13 +527,7 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a human-readable label for an item.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param $item
|
|
|
|
- * An item of this controller's type.
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- * Either a human-readable label for the item, or NULL if none is available.
|
|
|
|
*/
|
|
*/
|
|
public function getItemLabel($item) {
|
|
public function getItemLabel($item) {
|
|
$label = $this->getMetadataWrapper($item)->label();
|
|
$label = $this->getMetadataWrapper($item)->label();
|
|
@@ -384,33 +535,14 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a URL at which the item can be viewed on the web.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param $item
|
|
|
|
- * An item of this controller's type.
|
|
|
|
- *
|
|
|
|
- * @return
|
|
|
|
- * 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.
|
|
|
|
*/
|
|
*/
|
|
public function getItemUrl($item) {
|
|
public function getItemUrl($item) {
|
|
return NULL;
|
|
return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Initialize tracking of the index status of items for the given indexes.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * All currently known items of this data source's type should be inserted
|
|
|
|
- * into the tracking table for the given indexes, with status "changed". If
|
|
|
|
- * items were already present, these should also be set to "changed" and not
|
|
|
|
- * be inserted again.
|
|
|
|
- *
|
|
|
|
- * @param array $indexes
|
|
|
|
- * The SearchApiIndex objects for which item tracking should be initialized.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function startTracking(array $indexes) {
|
|
public function startTracking(array $indexes) {
|
|
if (!$this->table) {
|
|
if (!$this->table) {
|
|
@@ -424,27 +556,23 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Helper method that can be used by subclasses instead of implementing startTracking().
|
|
|
|
- *
|
|
|
|
* Returns the IDs of all items that are known for this controller's type.
|
|
* Returns the IDs of all items that are known for this controller's type.
|
|
*
|
|
*
|
|
|
|
+ * Helper method that can be used by subclasses instead of implementing
|
|
|
|
+ * startTracking().
|
|
|
|
+ *
|
|
* @return array
|
|
* @return array
|
|
* An array containing all item IDs for this type.
|
|
* An array containing all item IDs for this type.
|
|
|
|
+ *
|
|
|
|
+ * @throws SearchApiDataSourceException
|
|
|
|
+ * If any error state was encountered.
|
|
*/
|
|
*/
|
|
protected function getAllItemIds() {
|
|
protected function getAllItemIds() {
|
|
throw new SearchApiDataSourceException(t('Items not known for type @type.', array('@type' => $this->type)));
|
|
throw new SearchApiDataSourceException(t('Items not known for type @type.', array('@type' => $this->type)));
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Stop tracking of the index status of items for the given indexes.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * The tracking tables of the given indexes should be completely cleared.
|
|
|
|
- *
|
|
|
|
- * @param array $indexes
|
|
|
|
- * The SearchApiIndex objects for which item tracking should be stopped.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function stopTracking(array $indexes) {
|
|
public function stopTracking(array $indexes) {
|
|
if (!$this->table) {
|
|
if (!$this->table) {
|
|
@@ -454,28 +582,24 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
// will mostly be called with only one index.
|
|
// will mostly be called with only one index.
|
|
foreach ($indexes as $index) {
|
|
foreach ($indexes as $index) {
|
|
$this->checkIndex($index);
|
|
$this->checkIndex($index);
|
|
- $query = db_delete($this->table)
|
|
+ db_delete($this->table)
|
|
->condition($this->indexIdColumn, $index->id)
|
|
->condition($this->indexIdColumn, $index->id)
|
|
->execute();
|
|
->execute();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Start tracking the index status for the given items on the given indexes.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param array $item_ids
|
|
|
|
- * The IDs of new items to track.
|
|
|
|
- * @param array $indexes
|
|
|
|
- * The indexes for which items should be tracked.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function trackItemInsert(array $item_ids, array $indexes) {
|
|
public function trackItemInsert(array $item_ids, array $indexes) {
|
|
- if (!$this->table) {
|
|
+ if (!$this->table || $item_ids === array()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ foreach ($indexes as $index) {
|
|
|
|
+ $this->checkIndex($index);
|
|
|
|
+ }
|
|
|
|
+
|
|
// Since large amounts of items can overstrain the database, only add items
|
|
// Since large amounts of items can overstrain the database, only add items
|
|
// in chunks.
|
|
// in chunks.
|
|
foreach (array_chunk($item_ids, 1000) as $chunk) {
|
|
foreach (array_chunk($item_ids, 1000) as $chunk) {
|
|
@@ -483,7 +607,6 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
->fields(array($this->itemIdColumn, $this->indexIdColumn, $this->changedColumn));
|
|
->fields(array($this->itemIdColumn, $this->indexIdColumn, $this->changedColumn));
|
|
foreach ($chunk as $item_id) {
|
|
foreach ($chunk as $item_id) {
|
|
foreach ($indexes as $index) {
|
|
foreach ($indexes as $index) {
|
|
- $this->checkIndex($index);
|
|
|
|
$insert->values(array(
|
|
$insert->values(array(
|
|
$this->itemIdColumn => $item_id,
|
|
$this->itemIdColumn => $item_id,
|
|
$this->indexIdColumn => $index->id,
|
|
$this->indexIdColumn => $index->id,
|
|
@@ -496,60 +619,53 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "changed"/"dirty".
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * Unless $dequeue is set to TRUE, this operation is ignored for items whose
|
|
|
|
- * status is not "indexed".
|
|
|
|
- *
|
|
|
|
- * @param $item_ids
|
|
|
|
- * Either an array with the IDs of the changed items. Or FALSE to mark all
|
|
|
|
- * items as changed for the given indexes.
|
|
|
|
- * @param array $indexes
|
|
|
|
- * The indexes for which the change should be tracked.
|
|
|
|
- * @param $dequeue
|
|
|
|
- * If set to TRUE, also change the status of queued items.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function trackItemChange($item_ids, array $indexes, $dequeue = FALSE) {
|
|
public function trackItemChange($item_ids, array $indexes, $dequeue = FALSE) {
|
|
- if (!$this->table) {
|
|
+ if (!$this->table || $item_ids === array()) {
|
|
- return;
|
|
+ return NULL;
|
|
}
|
|
}
|
|
- $index_ids = array();
|
|
+
|
|
|
|
+ $indexes_by_id = array();
|
|
foreach ($indexes as $index) {
|
|
foreach ($indexes as $index) {
|
|
$this->checkIndex($index);
|
|
$this->checkIndex($index);
|
|
- $index_ids[] = $index->id;
|
|
+ $update = db_update($this->table)
|
|
|
|
+ ->fields(array(
|
|
|
|
+ $this->changedColumn => REQUEST_TIME,
|
|
|
|
+ ))
|
|
|
|
+ ->condition($this->indexIdColumn, $index->id)
|
|
|
|
+ ->condition($this->changedColumn, 0, $dequeue ? '<=' : '=');
|
|
|
|
+ if ($item_ids !== FALSE) {
|
|
|
|
+ $update->condition($this->itemIdColumn, $item_ids, 'IN');
|
|
|
|
+ }
|
|
|
|
+ $update->execute();
|
|
|
|
+ $indexes_by_id[$index->id] = $index;
|
|
}
|
|
}
|
|
- $update = db_update($this->table)
|
|
+
|
|
- ->fields(array(
|
|
+ // Determine and return the indexes with any changed items. If $item_ids is
|
|
- $this->changedColumn => REQUEST_TIME,
|
|
+ // FALSE, all items are marked as changed and, thus, all indexes will be
|
|
- ))
|
|
+ // affected (unless they don't have any items, but no real point in treating
|
|
- ->condition($this->indexIdColumn, $index_ids, 'IN')
|
|
+ // that special case).
|
|
- ->condition($this->changedColumn, 0, $dequeue ? '<=' : '=');
|
|
|
|
if ($item_ids !== FALSE) {
|
|
if ($item_ids !== FALSE) {
|
|
- $update->condition($this->itemIdColumn, $item_ids, 'IN');
|
|
+ $indexes_with_items = db_select($this->table, 't')
|
|
|
|
+ ->fields('t', array($this->indexIdColumn))
|
|
|
|
+ ->distinct()
|
|
|
|
+ ->condition($this->indexIdColumn, array_keys($indexes_by_id), 'IN')
|
|
|
|
+ ->condition($this->itemIdColumn, $item_ids, 'IN')
|
|
|
|
+ ->execute()
|
|
|
|
+ ->fetchCol();
|
|
|
|
+ return array_intersect_key($indexes_by_id, array_flip($indexes_with_items));
|
|
}
|
|
}
|
|
- $update->execute();
|
|
+
|
|
|
|
+ return NULL;
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "queued".
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * Queued items are not marked as "dirty" even when they are changed, and they
|
|
|
|
- * are not returned by the getChangedItems() method.
|
|
|
|
- *
|
|
|
|
- * @param $item_ids
|
|
|
|
- * Either an array with the IDs of the queued items. Or FALSE to mark all
|
|
|
|
- * items as queued for the given indexes.
|
|
|
|
- * @param SearchApiIndex $index
|
|
|
|
- * The index for which the items were queued.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function trackItemQueued($item_ids, SearchApiIndex $index) {
|
|
public function trackItemQueued($item_ids, SearchApiIndex $index) {
|
|
- if (!$this->table) {
|
|
+ $this->checkIndex($index);
|
|
|
|
+ if (!$this->table || $item_ids === array()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
$update = db_update($this->table)
|
|
$update = db_update($this->table)
|
|
@@ -564,18 +680,10 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Set the tracking status of the given items to "indexed".
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param array $item_ids
|
|
|
|
- * The IDs of the indexed items.
|
|
|
|
- * @param SearchApiIndex $indexes
|
|
|
|
- * The index on which the items were indexed.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If the index doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function trackItemIndexed(array $item_ids, SearchApiIndex $index) {
|
|
public function trackItemIndexed(array $item_ids, SearchApiIndex $index) {
|
|
- if (!$this->table) {
|
|
+ if (!$this->table || $item_ids === array()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
$this->checkIndex($index);
|
|
$this->checkIndex($index);
|
|
@@ -589,45 +697,30 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Stop tracking the index status for the given items on the given indexes.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param array $item_ids
|
|
|
|
- * The IDs of the removed items.
|
|
|
|
- * @param array $indexes
|
|
|
|
- * The indexes for which the deletions should be tracked.
|
|
|
|
- *
|
|
|
|
- * @throws SearchApiDataSourceException
|
|
|
|
- * If any of the indexes doesn't use the same item type as this controller.
|
|
|
|
*/
|
|
*/
|
|
public function trackItemDelete(array $item_ids, array $indexes) {
|
|
public function trackItemDelete(array $item_ids, array $indexes) {
|
|
- if (!$this->table) {
|
|
+ if (!$this->table || $item_ids === array()) {
|
|
- return;
|
|
+ return NULL;
|
|
}
|
|
}
|
|
- $index_ids = array();
|
|
+
|
|
|
|
+ $ret = array();
|
|
|
|
+
|
|
foreach ($indexes as $index) {
|
|
foreach ($indexes as $index) {
|
|
$this->checkIndex($index);
|
|
$this->checkIndex($index);
|
|
- $index_ids[] = $index->id;
|
|
+ $delete = db_delete($this->table)
|
|
|
|
+ ->condition($this->indexIdColumn, $index->id)
|
|
|
|
+ ->condition($this->itemIdColumn, $item_ids, 'IN');
|
|
|
|
+ if ($delete->execute()) {
|
|
|
|
+ $ret[] = $index;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- db_delete($this->table)
|
|
+
|
|
- ->condition($this->itemIdColumn, $item_ids, 'IN')
|
|
+ return $ret;
|
|
- ->condition($this->indexIdColumn, $index_ids, 'IN')
|
|
|
|
- ->execute();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get a list of items that need to be indexed.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * If possible, completely unindexed items should be returned before items
|
|
|
|
- * that were indexed but later changed. Also, items that were changed longer
|
|
|
|
- * ago should be favored.
|
|
|
|
- *
|
|
|
|
- * @param SearchApiIndex $index
|
|
|
|
- * The index for which changed items should be returned.
|
|
|
|
- * @param $limit
|
|
|
|
- * The maximum number of items to return. Negative values mean "unlimited".
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- * The IDs of items that need to be indexed for the given index.
|
|
|
|
*/
|
|
*/
|
|
public function getChangedItems(SearchApiIndex $index, $limit = -1) {
|
|
public function getChangedItems(SearchApiIndex $index, $limit = -1) {
|
|
if ($limit == 0) {
|
|
if ($limit == 0) {
|
|
@@ -635,7 +728,7 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
$this->checkIndex($index);
|
|
$this->checkIndex($index);
|
|
$select = db_select($this->table, 't');
|
|
$select = db_select($this->table, 't');
|
|
- $select->addField('t', 'item_id');
|
|
+ $select->addField('t', $this->itemIdColumn);
|
|
$select->condition($this->indexIdColumn, $index->id);
|
|
$select->condition($this->indexIdColumn, $index->id);
|
|
$select->condition($this->changedColumn, 0, '>');
|
|
$select->condition($this->changedColumn, 0, '>');
|
|
$select->orderBy($this->changedColumn, 'ASC');
|
|
$select->orderBy($this->changedColumn, 'ASC');
|
|
@@ -646,16 +739,7 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Get information on how many items have been indexed for a certain index.
|
|
+ * {@inheritdoc}
|
|
- *
|
|
|
|
- * @param SearchApiIndex $index
|
|
|
|
- * The index whose index status should be returned.
|
|
|
|
- *
|
|
|
|
- * @return array
|
|
|
|
- * An associative array containing two keys (in this order):
|
|
|
|
- * - indexed: The number of items already indexed in their latest version.
|
|
|
|
- * - total: The total number of items that have to be indexed for this
|
|
|
|
- * index.
|
|
|
|
*/
|
|
*/
|
|
public function getIndexStatus(SearchApiIndex $index) {
|
|
public function getIndexStatus(SearchApiIndex $index) {
|
|
if (!$this->table) {
|
|
if (!$this->table) {
|
|
@@ -677,20 +761,51 @@ abstract class SearchApiAbstractDataSourceController implements SearchApiDataSou
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * Helper method for ensuring that an index uses the same item type as this controller.
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function configurationForm(array $form, array &$form_state) {
|
|
|
|
+ return FALSE;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function configurationFormValidate(array $form, array &$values, array &$form_state) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function configurationFormSubmit(array $form, array &$values, array &$form_state) {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * {@inheritdoc}
|
|
|
|
+ */
|
|
|
|
+ public function getConfigurationSummary(SearchApiIndex $index) {
|
|
|
|
+ return NULL;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * Checks whether the given index is valid for this datasource controller.
|
|
|
|
+ *
|
|
|
|
+ * Helper method used by various methods in this class. By default only checks
|
|
|
|
+ * whether the types match.
|
|
*
|
|
*
|
|
* @param SearchApiIndex $index
|
|
* @param SearchApiIndex $index
|
|
* The index to check.
|
|
* The index to check.
|
|
*
|
|
*
|
|
* @throws SearchApiDataSourceException
|
|
* @throws SearchApiDataSourceException
|
|
- * If the index doesn't use the same type as this controller.
|
|
+ * If the index doesn't fit to this datasource controller.
|
|
*/
|
|
*/
|
|
protected function checkIndex(SearchApiIndex $index) {
|
|
protected function checkIndex(SearchApiIndex $index) {
|
|
if ($index->item_type != $this->type) {
|
|
if ($index->item_type != $this->type) {
|
|
$index_type = search_api_get_item_type_info($index->item_type);
|
|
$index_type = search_api_get_item_type_info($index->item_type);
|
|
$index_type = empty($index_type['name']) ? $index->item_type : $index_type['name'];
|
|
$index_type = empty($index_type['name']) ? $index->item_type : $index_type['name'];
|
|
- $msg = t('Invalid index @index of type @index_type passed to data source controller for type @this_type.',
|
|
+ $msg = t(
|
|
- array('@index' => $index->name, '@index_type' => $index_type, '@this_type' => $this->info['name']));
|
|
+ 'Invalid index @index of type @index_type passed to data source controller for type @this_type.',
|
|
|
|
+ array('@index' => $index->name, '@index_type' => $index_type, '@this_type' => $this->info['name'])
|
|
|
|
+ );
|
|
throw new SearchApiDataSourceException($msg);
|
|
throw new SearchApiDataSourceException($msg);
|
|
}
|
|
}
|
|
}
|
|
}
|