You are here

CanonicalUrlProperty.php in Search API Field Map 8

File

src/Plugin/search_api/processor/Property/CanonicalUrlProperty.php
View source
<?php

namespace Drupal\search_api_field_map\Plugin\search_api\processor\Property;

use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\StringTranslation\StringTranslationTrait;
use Drupal\search_api\Item\FieldInterface;
use Drupal\search_api\Processor\ConfigurablePropertyBase;

/**
 * Defines a "Canonical URL" property.
 *
 * @see \Drupal\search_api\Plugin\search_api\processor\Urls
 */
class CanonicalUrlProperty extends ConfigurablePropertyBase {
  use StringTranslationTrait;

  /**
   * {@inheritdoc}
   */
  public function defaultConfiguration() {
    return [
      'canonical_url' => '',
    ];
  }

  /**
   * {@inheritdoc}
   */
  public function buildConfigurationForm(FieldInterface $field, array $form, FormStateInterface $form_state) {
    $form['#attached']['library'][] = 'search_api/drupal.search_api.admin_css';
    $form['#tree'] = TRUE;
    $form['field_data'] = [
      '#type' => 'item',
      '#title' => $this
        ->t('Canonical URL'),
      '#description' => $this
        ->t('Preferred URL for this content.'),
    ];
    return $form;
  }

}

Classes

Namesort descending Description
CanonicalUrlProperty Defines a "Canonical URL" property.