You are here

public function GoogleScholar::buildUrl in Bibliography & Citation 2.0.x

Same name and namespace in other branches
  1. 8 modules/bibcite_entity/src/Plugin/bibcite/link/GoogleScholar.php \Drupal\bibcite_entity\Plugin\bibcite\link\GoogleScholar::buildUrl()

Build URL object.

Parameters

\Drupal\bibcite_entity\Entity\ReferenceInterface $reference: Reference entity object.

Overrides BibciteLinkPluginBase::buildUrl

File

modules/bibcite_entity/src/Plugin/bibcite/link/GoogleScholar.php, line 22

Class

GoogleScholar
Build Google Scholar lookup link.

Namespace

Drupal\bibcite_entity\Plugin\bibcite\link

Code

public function buildUrl(ReferenceInterface $reference) {
  $title_field = $reference
    ->get('title');
  if (!$title_field
    ->isEmpty()) {
    return Url::fromUri('https://scholar.google.com/scholar', [
      'query' => [
        'btnG' => 'Search+Scholar',
        'as_q' => '"' . str_replace([
          ' ',
          '(',
          ')',
        ], [
          '+',
        ], $title_field->value) . '"',
        'as_occt' => 'any',
        'as_epq' => '',
        'as_oq' => '',
        'as_eq' => '',
        'as_publication' => '',
        'as_ylo' => '',
        'as_yhi' => '',
        'as_sdtAAP' => 1,
        'as_sdtp' => 1,
      ],
    ]);
  }
  return NULL;
}