class RowFieldset in Views fieldsets 8.3
Hierarchy
- class \Drupal\views_fieldsets\RowFieldset
Expanded class hierarchy of RowFieldset
1 file declares its use of RowFieldset
- Fieldset.php in src/
Plugin/ views/ field/ Fieldset.php
File
- src/
RowFieldset.php, line 14
Namespace
Drupal\views_fieldsetsView source
class RowFieldset {
public $row;
public $properties = [];
public $children = [];
/**
* Constructs an RowFieldset object.
*/
public function __construct($field, ResultRow $row) {
$this->row = $row;
$this->properties = get_object_vars($field);
}
/**
* Magic method: __isset a property value.
*
* @param string $name
* Method's name.
*/
public function __isset($name) {
return TRUE;
}
/**
* Magic method: Gets a property value.
*
* @param string $name
* Method's name.
*/
public function __get($name) {
$method_name = 'get' . Unicode::ucwords($name);
if (is_callable($method = [
$this,
$method_name,
])) {
return call_user_func($method);
}
if (!empty($name) && !empty($this->properties[$name])) {
return $this->properties[$name];
}
return FALSE;
}
/**
* Object getcontent().
*/
public function getContent() {
return $this
->render();
}
/**
* Object getwrapperelement().
*/
public function getWrapperelement() {
return '';
}
/**
* Object getelementtype().
*/
public function getElementtype() {
return '';
}
/**
* Object render().
*/
public function render() {
// @todo Theme hook suggestions!
$element = [
'#theme' => 'views_fieldsets_' . $this
->getWrapperType(),
'#fields' => $this->children,
'#legend' => Markup::create($this
->getLegend()),
'#collapsible' => (bool) $this->handler->options['collapsible'],
'#attributes' => [
'class' => $this
->getClasses(),
],
];
if ($this->handler->options['collapsed'] && $this
->getWrapperType() != 'div') {
$element['#attributes']['class'][] = 'collapsed';
}
return render($element);
}
/**
* Object getWrapperType().
*/
protected function getWrapperType() {
$allowed = Fieldset::getWrapperTypes();
$wrapper = $this->handler->options['wrapper'];
if (isset($allowed[$wrapper])) {
return $wrapper;
}
reset($allowed);
return key($allowed);
}
/**
* Object getLegend().
*/
protected function getLegend() {
return $this
->tokenize($this->handler->options['legend']);
}
/**
* Object getClasses().
*/
protected function getClasses() {
$classes = explode(' ', $this->handler->options['classes']);
$classes = array_map(function ($class) {
return Html::getClass($this
->tokenize($class));
}, $classes);
return $classes;
}
/**
* Object tokenize().
*
* @param string $string
* String.
*/
protected function tokenize($string) {
return $this->handler
->tokenizeValue($string, $this->row->index);
}
/**
* Object addChild().
*
* @param array $fields
* Fields.
* @param string $field_name
* Field name.
*/
public function addChild(array $fields, $field_name) {
$this->children[$field_name] = $fields[$field_name];
}
}
Members
Name![]() |
Modifiers | Type | Description | Overrides |
---|---|---|---|---|
RowFieldset:: |
public | property | ||
RowFieldset:: |
public | property | ||
RowFieldset:: |
public | property | ||
RowFieldset:: |
public | function | Object addChild(). | |
RowFieldset:: |
protected | function | Object getClasses(). | |
RowFieldset:: |
public | function | Object getcontent(). | |
RowFieldset:: |
public | function | Object getelementtype(). | |
RowFieldset:: |
protected | function | Object getLegend(). | |
RowFieldset:: |
public | function | Object getwrapperelement(). | |
RowFieldset:: |
protected | function | Object getWrapperType(). | |
RowFieldset:: |
public | function | Object render(). | |
RowFieldset:: |
protected | function | Object tokenize(). | |
RowFieldset:: |
public | function | Constructs an RowFieldset object. | |
RowFieldset:: |
public | function | Magic method: Gets a property value. | |
RowFieldset:: |
public | function | Magic method: __isset a property value. |