class CloudBlockBase in Gutenberg 8.2
Same name and namespace in other branches
- 8 modules/gutenberg_cloud/src/CloudBlockBase.php \Drupal\gutenberg_cloud\CloudBlockBase
Class CloudBlockBase.
Hierarchy
- class \Drupal\gutenberg_cloud\CloudBlockBase implements CloudBlockInterface
Expanded class hierarchy of CloudBlockBase
File
- modules/
gutenberg_cloud/ src/ CloudBlockBase.php, line 8
Namespace
Drupal\gutenberg_cloudView source
class CloudBlockBase implements CloudBlockInterface {
/**
* Block machine name.
*
* @var string
*/
protected $name;
/**
* Block version.
*
* @var string
*/
protected $version;
/**
* Block label (human readable name).
*
* @var string
*/
protected $label = '';
/**
* Block description.
*
* @var string
*/
protected $description = '';
/**
* Block screenshot.
*
* @var null
*/
protected $screenshot = NULL;
/**
* Block js.
*
* @var null
*/
protected $js = NULL;
/**
* Block edit css.
*
* @var null
*/
protected $edit_css = NULL;
/**
* Block view css.
*
* @var null
*/
protected $view_css = NULL;
/**
* CloudBlockBase constructor.
*
* @param array $block
* Cloud block structure.
*/
public function __construct(array $block) {
$this
->setConfig($block);
}
/**
* Getter for name.
*/
public function getName() {
return $this->name;
}
/**
* Getter for version.
*/
public function getVersion() {
return $this->version;
}
/**
* Getter for label.
*/
public function getLabel() {
return $this->label;
}
/**
* Getter for description.
*/
public function getDescription() {
return $this->description;
}
/**
* Getter for screenshot.
*/
public function getScreenshot() {
return $this->screenshot;
}
/**
* Getter for js.
*/
public function getJs() {
return $this->js;
}
/**
* Getter for edit css.
*/
public function getEditCss() {
return $this->edit_css;
}
/**
* Getter for view css.
*/
public function getViewCss() {
return $this->view_css;
}
/**
* Getter for object properties.
*
* @param string $property
* Property name.
*
* @return mixed|null
* Properety value or NULL if property doesn't exists.
*/
public function get(string $property) {
return $this
->getConfig()[$property] ?? NULL;
}
/**
* Getter for properties related to Cloud Block config.
*
* @return array
* Array of properties.
*/
public function getConfig() {
return [
'name' => $this->name,
'version' => $this->version,
'label' => $this->label,
'description' => $this->description,
'screenshot' => $this->screenshot,
'js' => $this->js,
'edit_css' => $this->edit_css,
'view_css' => $this->view_css,
];
}
/**
* Sets object properties based on a given array.
*
* @param array $config
* Associative array.
*/
protected function setConfig(array $config) {
foreach ($config as $property => $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
CloudBlockBase:: |
protected | property | Block description. | |
CloudBlockBase:: |
protected | property | Block edit css. | |
CloudBlockBase:: |
protected | property | Block js. | |
CloudBlockBase:: |
protected | property | Block label (human readable name). | |
CloudBlockBase:: |
protected | property | Block machine name. | |
CloudBlockBase:: |
protected | property | Block screenshot. | |
CloudBlockBase:: |
protected | property | Block version. | |
CloudBlockBase:: |
protected | property | Block view css. | |
CloudBlockBase:: |
public | function |
Getter for object properties. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for properties related to Cloud Block config. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for description. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for edit css. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for js. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for label. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for name. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for screenshot. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for version. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
public | function |
Getter for view css. Overrides CloudBlockInterface:: |
|
CloudBlockBase:: |
protected | function | Sets object properties based on a given array. | |
CloudBlockBase:: |
public | function | CloudBlockBase constructor. | 1 |