SectionStorageDefinition.php in Drupal 8
File
core/modules/layout_builder/src/SectionStorage/SectionStorageDefinition.php
View source
<?php
namespace Drupal\layout_builder\SectionStorage;
use Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionInterface;
use Drupal\Component\Plugin\Definition\ContextAwarePluginDefinitionTrait;
use Drupal\Component\Plugin\Definition\PluginDefinition;
class SectionStorageDefinition extends PluginDefinition implements ContextAwarePluginDefinitionInterface {
use ContextAwarePluginDefinitionTrait;
protected $weight = 0;
protected $additional = [];
public function __construct(array $definition = []) {
if (isset($definition['context_definitions'])) {
foreach ($definition['context_definitions'] as $name => $context_definition) {
$this
->addContextDefinition($name, $context_definition);
}
unset($definition['context_definitions']);
}
foreach ($definition as $property => $value) {
$this
->set($property, $value);
}
}
public function get($property) {
if (property_exists($this, $property)) {
$value = isset($this->{$property}) ? $this->{$property} : NULL;
}
else {
$value = isset($this->additional[$property]) ? $this->additional[$property] : NULL;
}
return $value;
}
public function set($property, $value) {
if (property_exists($this, $property)) {
$this->{$property} = $value;
}
else {
$this->additional[$property] = $value;
}
return $this;
}
public function getWeight() {
return $this->weight;
}
}