You are here

class SchemaActionBase in Schema.org Metatag 7

Schema.org Action items should extend this class.

Hierarchy

Expanded class hierarchy of SchemaActionBase

2 string references to 'SchemaActionBase'
SchemaCreativeWorkTrait::creativeWorkProperties in src/SchemaCreativeWorkTrait.php
Return an array of the unique properties for an object type.
SchemaHasPartTrait::hasPartProperties in src/SchemaHasPartTrait.php
Return an array of the unique properties for an object type.

File

src/SchemaActionBase.php, line 6

View source
class SchemaActionBase extends SchemaNameBase {
  use SchemaActionTrait;

  /**
   * Allowed actions.
   *
   * @var array
   */
  protected $actions;

  /**
   * {@inheritdoc}
   */
  public function __construct(array $info, array $data = NULL) {
    parent::__construct($info, $data);
    $this->actions = [];
  }

  /**
   * {@inheritdoc}
   */
  public function getForm(array $options = []) {
    $value = $this
      ->schemaMetatagManager()
      ->unserialize($this
      ->value());
    $input_values = [
      'title' => $this
        ->label(),
      'description' => $this
        ->description(),
      'value' => $value,
      '#required' => isset($options['#required']) ? $options['#required'] : FALSE,
      'visibility_selector' => $this
        ->visibilitySelector(),
      'actions' => $this->actions,
    ];
    $form['value'] = $this
      ->actionForm($input_values);
    if (empty($this
      ->multiple())) {
      unset($form['value']['pivot']);
    }

    // Validation from parent::getForm() got wiped out, so add callback.
    $form['value']['#element_validate'][] = 'schema_metatag_element_validate';
    return $form;
  }

  /**
   * {@inheritdoc}
   */
  public static function testValue() {
    $items = [];
    $keys = [
      '@type',
      'target',
    ];
    foreach ($keys as $key) {
      switch ($key) {
        case '@type':
          $items[$key] = 'Action';
          break;
        case 'target':
          $items[$key] = SchemaEntryPointBase::testValue();
          break;
        default:
          $items[$key] = parent::testDefaultValue(1, '');
          break;
      }
    }
    return $items;
  }

  /**
   * {@inheritdoc}
   */
  public static function processedTestValue($items) {
    foreach ($items as $key => $value) {
      switch ($key) {
        case 'target':
          $items[$key] = SchemaEntryPointBase::processedTestValue($items[$key]);
          break;
      }
    }
    return $items;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
DrupalDefaultMetaTag::$data protected property The values submitted for this tag.
DrupalDefaultMetaTag::$info protected property All of the basic information about this tag.
DrupalDefaultMetaTag::$weight protected property This item's weight; used for sorting the output.
DrupalDefaultMetaTag::convertUrlToAbsolute protected function Make sure a given URL is absolute.
DrupalDefaultMetaTag::getWeight public function Calculate the weight of this meta tag. Overrides DrupalMetaTagInterface::getWeight
DrupalDefaultMetaTag::maxlength protected function Identify the maximum length of which strings will be allowed.
DrupalDefaultMetaTag::textSummary public static function Copied from text.module with the following changes:. Overrides DrupalMetaTagInterface::textSummary
DrupalDefaultMetaTag::tidyValue protected function Remove unwanted formatting from a meta tag.
DrupalDefaultMetaTag::truncate protected function Shorten a string to a certain length using ::textSummary().
DrupalTextMetaTag::getValue public function Get the string value of this meta tag. Overrides DrupalDefaultMetaTag::getValue 1
SchemaActionBase::$actions protected property Allowed actions.
SchemaActionBase::getForm public function Build the form for this meta tag. Overrides SchemaNameBase::getForm 3
SchemaActionBase::processedTestValue public static function Provide a test output value for the input value. Overrides SchemaNameBase::processedTestValue
SchemaActionBase::testValue public static function Provide a test input value for the property that will validate. Overrides SchemaNameBase::testValue
SchemaActionBase::__construct public function Constructor. Overrides SchemaNameBase::__construct
SchemaActionTrait::actionForm public function Create the form element.
SchemaActionTrait::actionObjects public static function Return an array of all actions for an action type.
SchemaActionTrait::actionProperties public static function Return an array of the unique properties for an action type.
SchemaActionTrait::actionTypes public static function All action types.
SchemaActionTrait::getActionType public static function Get the action type for a given action.
SchemaActionTrait::getAllActions public static function Get an array of all actions, grouped by action type.
SchemaActionTrait::schemaMetatagManager abstract protected function Return the SchemaMetatagManager. Overrides SchemaPersonOrgTrait::schemaMetatagManager 1
SchemaImageTrait::imageForm public function The form element.
SchemaNameBase::$schemaMetatagManager protected property The schemaMetatagManager service.
SchemaNameBase::description public function
SchemaNameBase::getElement public function Get the HTML tag for this meta tag. Overrides DrupalDefaultMetaTag::getElement 1
SchemaNameBase::getPluginId public function
SchemaNameBase::label public function
SchemaNameBase::multiple public function
SchemaNameBase::neverExplode public static function Nested elements that cannot be exploded.
SchemaNameBase::outputValue public static function Transform input value to its display output. Overrides SchemaMetatagTestTagInterface::outputValue 2
SchemaNameBase::pivotItem public static function
SchemaNameBase::processItem protected function Process an individual item.
SchemaNameBase::processTestExplodeValue public static function Explode a test value. Overrides SchemaMetatagTestTagInterface::processTestExplodeValue
SchemaNameBase::randomUrl public static function Random absolute url for testing. Overrides SchemaMetatagTestTagInterface::randomUrl
SchemaNameBase::t public function
SchemaNameBase::testDefaultValue public static function Provide a random test value. Overrides SchemaMetatagTestTagInterface::testDefaultValue
SchemaNameBase::value public function
SchemaNameBase::visibilitySelector protected function The #states visibility selector for this element.
SchemaPersonOrgTrait::personOrgForm public function The form element.