class Robots in Metatag 8
The basic "Robots" meta tag.
Plugin annotation
@MetatagTag(
  id = "robots",
  label = @Translation("Robots"),
  description = @Translation("Provides search engines with specific directions for what to do when this page is indexed."),
  name = "robots",
  group = "advanced",
  weight = 1,
  type = "string",
  secure = FALSE,
  multiple = FALSE
)
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements DerivativeInspectionInterface, PluginInspectionInterface- class \Drupal\metatag\Plugin\metatag\Tag\MetaNameBase uses StringTranslationTrait- class \Drupal\metatag\Plugin\metatag\Tag\Robots uses StringTranslationTrait
 
 
- class \Drupal\metatag\Plugin\metatag\Tag\MetaNameBase uses StringTranslationTrait
Expanded class hierarchy of Robots
1 string reference to 'Robots'
- metatag.metatag_tag.schema.yml in config/schema/ metatag.metatag_tag.schema.yml 
- config/schema/metatag.metatag_tag.schema.yml
File
- src/Plugin/ metatag/ Tag/ Robots.php, line 22 
Namespace
Drupal\metatag\Plugin\metatag\TagView source
class Robots extends MetaNameBase {
  use StringTranslationTrait;
  /**
   * Sets the value of this tag.
   *
   * @param string|array $value
   *   The value to set to this tag.
   *   It can be an array if it comes from a form submission or from field
   *   defaults, in which case
   *   we transform it to a comma-separated string.
   */
  public function setValue($value) {
    if (is_array($value)) {
      $value = array_filter($value);
      $value = implode(', ', array_keys($value));
    }
    $this->value = $value;
  }
  /**
   * {@inheritdoc}
   */
  public function form(array $element = []) {
    // Prepare the default value as it is stored as a string.
    $default_value = [];
    if (!empty($this->value)) {
      $default_value = explode(', ', $this->value);
    }
    $form = [
      '#type' => 'checkboxes',
      '#title' => $this
        ->label(),
      '#description' => $this
        ->description(),
      '#options' => [
        'index' => $this
          ->t('index - Allow search engines to index this page (assumed).'),
        'follow' => $this
          ->t('follow - Allow search engines to follow links on this page (assumed).'),
        'noindex' => $this
          ->t('noindex - Prevents search engines from indexing this page.'),
        'nofollow' => $this
          ->t('nofollow - Prevents search engines from following links on this page.'),
        'noarchive' => $this
          ->t('noarchive - Prevents cached copies of this page from appearing in search results.'),
        'nosnippet' => $this
          ->t('nosnippet - Prevents descriptions from appearing in search results, and prevents page caching.'),
        'noodp' => $this
          ->t('noodp - Blocks the <a href=":opendirectory">Open Directory Project</a> description from appearing in search results.', [
          ':opendirectory' => 'http://www.dmoz.org/',
        ]),
        'noydir' => $this
          ->t('noydir - Prevents Yahoo! from listing this page in the <a href=":ydir">Yahoo! Directory</a>.', [
          ':ydir' => 'http://dir.yahoo.com/',
        ]),
        'noimageindex' => $this
          ->t('noimageindex - Prevent search engines from indexing images on this page.'),
        'notranslate' => $this
          ->t('notranslate - Prevent search engines from offering to translate this page in search results.'),
      ],
      'index' => [
        '#states' => [
          'disabled' => [
            [
              ':input[name="robots[noindex]"]' => [
                'checked' => TRUE,
              ],
            ],
            'or',
            [
              ':input[name*="[robots][noindex]"]' => [
                'checked' => TRUE,
              ],
            ],
          ],
        ],
      ],
      'noindex' => [
        '#states' => [
          'disabled' => [
            [
              ':input[name="robots[index]"]' => [
                'checked' => TRUE,
              ],
            ],
            'or',
            [
              ':input[name*="[robots][index]"]' => [
                'checked' => TRUE,
              ],
            ],
          ],
        ],
      ],
      'follow' => [
        '#states' => [
          'disabled' => [
            [
              ':input[name="robots[nofollow]"]' => [
                'checked' => TRUE,
              ],
            ],
            'or',
            [
              ':input[name*="[robots][nofollow]"]' => [
                'checked' => TRUE,
              ],
            ],
          ],
        ],
      ],
      'nofollow' => [
        '#states' => [
          'disabled' => [
            [
              ':input[name="robots[follow]"]' => [
                'checked' => TRUE,
              ],
            ],
            'or',
            [
              ':input[name*="[robots][follow]"]' => [
                'checked' => TRUE,
              ],
            ],
          ],
        ],
      ],
      '#default_value' => $default_value,
      '#required' => isset($element['#required']) ? $element['#required'] : FALSE,
      '#element_validate' => [
        [
          get_class($this),
          'validateTag',
        ],
      ],
    ];
    return $form;
  }
}Members
| Name   | Modifiers | Type | Description | Overrides | 
|---|---|---|---|---|
| MetaNameBase:: | protected | property | True if the URL value(s) must be absolute. | |
| MetaNameBase:: | protected | property | A longer explanation of what the field is for. | |
| MetaNameBase:: | protected | property | The category this meta tag fits in. | |
| MetaNameBase:: | protected | property | Machine name of the meta tag plugin. | |
| MetaNameBase:: | protected | property | The title of the plugin. | |
| MetaNameBase:: | protected | property | True if the tag should use a text area. | |
| MetaNameBase:: | protected | property | True if more than one is allowed. | |
| MetaNameBase:: | protected | property | Official metatag name. | 1 | 
| MetaNameBase:: | protected | property | The attribute this tag uses for the name. | 3 | 
| MetaNameBase:: | protected | property | Retrieves the currently active request object. | |
| MetaNameBase:: | protected | property | True if URL must use HTTPS. | |
| MetaNameBase:: | protected | property | Type of the value being stored. | |
| MetaNameBase:: | protected | property | The value of the metatag in this instance. | |
| MetaNameBase:: | public | function | The meta tag's description. | |
| MetaNameBase:: | public | function | The meta tag group this meta tag belongs to. | |
| MetaNameBase:: | public | function | Obtain the meta tag's internal ID. | |
| MetaNameBase:: | public | function | Whether or not this meta tag is active. | |
| MetaNameBase:: | public | function | Whether or not this meta tag should use a text area. | |
| MetaNameBase:: | public | function | This meta tag's label. | |
| MetaNameBase:: | public | function | Whether or not this meta tag supports multiple values. | |
| MetaNameBase:: | public | function | The meta tag's machine name. | 1 | 
| MetaNameBase:: | public | function | Generate the HTML tag output for a meta tag. | 1 | 
| MetaNameBase:: | protected | function | Extract any image URLs that might be found in a meta tag. | |
| MetaNameBase:: | public | function | Whether or not this meta tag must output required absolute URLs. | |
| MetaNameBase:: | public | function | Whether or not this meta tag must output secure (HTTPS) URLs. | |
| MetaNameBase:: | private | function | Make the string presentable. | |
| MetaNameBase:: | public | function | Obtain this meta tag's type. | |
| MetaNameBase:: | public static | function | Validates the metatag data. | |
| MetaNameBase:: | public | function | Obtain the current meta tag's raw value. | |
| MetaNameBase:: | public | function | This meta tag's form field's weight. | |
| MetaNameBase:: | public | function | Constructs a \Drupal\Component\Plugin\PluginBase object. Overrides PluginBase:: | |
| PluginBase:: | protected | property | Configuration information passed into the plugin. | 1 | 
| PluginBase:: | protected | property | The plugin implementation definition. | 1 | 
| PluginBase:: | protected | property | The plugin_id. | |
| PluginBase:: | constant | A string which is used to separate base plugin IDs from the derivative ID. | ||
| PluginBase:: | public | function | Gets the base_plugin_id of the plugin instance. Overrides DerivativeInspectionInterface:: | |
| PluginBase:: | public | function | Gets the derivative_id of the plugin instance. Overrides DerivativeInspectionInterface:: | |
| PluginBase:: | public | function | Gets the definition of the plugin implementation. Overrides PluginInspectionInterface:: | 3 | 
| PluginBase:: | public | function | Gets the plugin_id of the plugin instance. Overrides PluginInspectionInterface:: | |
| PluginBase:: | public | function | Determines if the plugin is configurable. | |
| Robots:: | public | function | Generate a form element for this meta tag. Overrides MetaNameBase:: | |
| Robots:: | public | function | Sets the value of this tag. Overrides MetaNameBase:: | |
| StringTranslationTrait:: | protected | property | The string translation service. | 1 | 
| StringTranslationTrait:: | protected | function | Formats a string containing a count of items. | |
| StringTranslationTrait:: | protected | function | Returns the number of plurals supported by a given language. | |
| StringTranslationTrait:: | protected | function | Gets the string translation service. | |
| StringTranslationTrait:: | public | function | Sets the string translation service to use. | 2 | 
| StringTranslationTrait:: | protected | function | Translates a string to the current language or to a given language. | 
