class AttributeBase
Same name in other branches
- 11.x core/lib/Drupal/Component/Plugin/Attribute/AttributeBase.php \Drupal\Component\Plugin\Attribute\AttributeBase
Provides a base class for classed attributes.
Hierarchy
- class \Drupal\Component\Plugin\Attribute\AttributeBase implements \Drupal\Component\Plugin\Attribute\AttributeInterface
Expanded class hierarchy of AttributeBase
1 file declares its use of AttributeBase
- AttributeBaseTest.php in core/
tests/ Drupal/ Tests/ Component/ Plugin/ Attribute/ AttributeBaseTest.php
File
-
core/
lib/ Drupal/ Component/ Plugin/ Attribute/ AttributeBase.php, line 8
Namespace
Drupal\Component\Plugin\AttributeView source
abstract class AttributeBase implements AttributeInterface {
/**
* The class used for this attribute class.
*
* @var class-string
*/
protected string $class;
/**
* The provider of the attribute class.
*/
protected string|null $provider = NULL;
/**
* @param string $id
* The attribute class ID.
*/
public function __construct(string $id) {
}
/**
* {@inheritdoc}
*/
public function getProvider() : ?string {
return $this->provider;
}
/**
* {@inheritdoc}
*/
public function setProvider(string $provider) : void {
$this->provider = $provider;
}
/**
* {@inheritdoc}
*/
public function getId() : string {
return $this->id;
}
/**
* {@inheritdoc}
*/
public function getClass() : string {
return $this->class;
}
/**
* {@inheritdoc}
*/
public function setClass(string $class) : void {
$this->class = $class;
}
/**
* {@inheritdoc}
*/
public function get() : array|object {
return array_filter(get_object_vars($this) + [
'class' => $this->getClass(),
'provider' => $this->getProvider(),
], function ($value, $key) {
return !($value === NULL && ($key === 'deriver' || $key === 'provider'));
}, ARRAY_FILTER_USE_BOTH);
}
}
Members
Title Sort descending | Modifiers | Object type | Summary | Overriden Title | Overrides |
---|---|---|---|---|---|
AttributeBase::$class | protected | property | The class used for this attribute class. | ||
AttributeBase::$provider | protected | property | The provider of the attribute class. | ||
AttributeBase::get | public | function | Gets the value of an attribute. | Overrides AttributeInterface::get | 6 |
AttributeBase::getClass | public | function | Gets the class of the attribute class. | Overrides AttributeInterface::getClass | 1 |
AttributeBase::getId | public | function | Gets the unique ID for this attribute class. | Overrides AttributeInterface::getId | |
AttributeBase::getProvider | public | function | Gets the name of the provider of the attribute class. | Overrides AttributeInterface::getProvider | |
AttributeBase::setClass | public | function | Sets the class of the attributed class. | Overrides AttributeInterface::setClass | 1 |
AttributeBase::setProvider | public | function | Sets the name of the provider of the attribute class. | Overrides AttributeInterface::setProvider | |
AttributeBase::__construct | public | function | 1 |
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.