Back to Microdata class

Method setType

public \Joomla\CMS\Microdata\Microdata
setType
(mixed $type)
Set a new http://schema.org Type
Parameters
  • string $type The $Type to be setup
Returns
  • \Joomla\CMS\Microdata\Microdata Instance of $this
Since
  • 3.2
Class: Microdata
Project: Joomla

Method setType - Source code

/**
 * Set a new http://schema.org Type
 *
 * @param   string  $type  The $Type to be setup
 *
 * @return  Microdata  Instance of $this
 *
 * @since   3.2
 */
public function setType($type)
{
    if (!$this->enabled) {
        return $this;
    }
    // Sanitize the Type
    $this->type = static::sanitizeType($type);
    // If the given $Type isn't available, fallback to 'Thing' Type
    if (!static::isTypeAvailable($this->type)) {
        $this->type = 'Thing';
    }
    return $this;
}