You are here

class AcquiaDAM_Search in Media: Acquia DAM 7

Acquia DAM Search requests.

@package AcquiaDAM

Hierarchy

Expanded class hierarchy of AcquiaDAM_Search

File

src/AcquiaDAM/AcquiaDAM_Search.inc, line 8

View source
class AcquiaDAM_Search {

  /**
   * A list of class dependencies.
   *
   * @var array
   */
  protected $depends = [];

  /**
   * AcquiaDAM_Search constructor.
   *
   * @param array $depends
   *   An array of class dependencies.
   */
  public function __construct(array $depends = []) {
    $this->depends = $depends;
    if (empty($this->depends['client'])) {
      $this->depends['client'] = AcquiaDAM_API::getClient();
    }
  }

  /**
   * Issue a search.
   *
   * @param string $phrase
   *   The keywords to search for.
   * @param array $options
   *   An array of options to pass to to the API request.
   *
   * @return array
   *   The result of the search request.
   */
  public function search($phrase, array $options = []) {
    $options += [
      'query' => $phrase,
      'folderid' => NULL,
      'sortby' => 'datecreated',
      'sortdir' => 'asc',
      'limit' => 50,
      'offset' => 0,
      'types' => '',
      'searchfield' => '',
      'facets' => 'all',
    ];
    if (is_array($options['types'])) {
      $options['types'] = implode(',', $options['types']);
    }
    return $this->depends['client']
      ->request('search', $options);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
AcquiaDAM_Search::$depends protected property A list of class dependencies.
AcquiaDAM_Search::search public function Issue a search.
AcquiaDAM_Search::__construct public function AcquiaDAM_Search constructor.