class FieldsPluginOptions in Layout Plugin Views 8
Same name and namespace in other branches
- 8.2 src/FieldsPluginOptions.php \Drupal\layout_plugin_views\FieldsPluginOptions
Hierarchy
- class \Drupal\layout_plugin_views\FieldsPluginOptions
Expanded class hierarchy of FieldsPluginOptions
1 file declares its use of FieldsPluginOptions
- Fields.php in src/
Plugin/ views/ row/ Fields.php
File
- src/
FieldsPluginOptions.php, line 9
Namespace
Drupal\layout_plugin_viewsView source
class FieldsPluginOptions {
/**
* @var \Drupal\layout_plugin_views\Plugin\views\row\Fields
*/
private $plugin;
/**
* @var \Drupal\layout_plugin\Plugin\Layout\LayoutPluginManagerInterface
*/
private $layoutPluginManager;
public static function fromFieldsPlugin(LayoutPluginManagerInterface $layoutPluginManager, Fields $plugin) {
return new static($layoutPluginManager, $plugin);
}
private function __construct(LayoutPluginManagerInterface $layoutPluginManager, Fields $plugin) {
$this->plugin = $plugin;
$this->layoutPluginManager = $layoutPluginManager;
}
/**
* Retrieves the machine name of the selected layout.
*
* @return string
*/
public function getLayout() {
return $this->plugin->options['layout'];
}
/**
* Retrieves the machine name of the region set to be the default region.
*
* @return string
*/
public function getDefaultRegion() {
return $this->plugin->options['default_region'];
}
/**
* Retrieves the region machine name that was assigned to the given field.
*
* @param string $field_machine_name
*
* @return string
* The machine name of the region that the given field is assigned to or an
* empty string if the field is not assigned to a region.
*/
public function getAssignedRegion($field_machine_name) {
if (isset($this->plugin->options['assigned_regions'][$field_machine_name])) {
return $this->plugin->options['assigned_regions'][$field_machine_name];
}
else {
return '';
}
}
/**
* @return bool
*/
public function hasValidSelectedLayout() {
return $this->layoutPluginManager
->hasDefinition($this
->getLayout());
}
/**
* Retrieves the definition of the selected layout.
*
* @return array
*/
public function getSelectedLayoutDefinition() {
return $this
->hasValidSelectedLayout() ? $this->layoutPluginManager
->getDefinition($this
->getLayout()) : [];
}
/**
* @return bool
*/
public function layoutFallbackIsPossible() {
return count($this->layoutPluginManager
->getDefinitions()) > 0;
}
/**
* @return array
*/
public function getFallbackLayoutDefinition() {
$definitions = $this->layoutPluginManager
->getDefinitions();
return array_shift($definitions);
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
FieldsPluginOptions:: |
private | property | ||
FieldsPluginOptions:: |
private | property | ||
FieldsPluginOptions:: |
public static | function | ||
FieldsPluginOptions:: |
public | function | Retrieves the region machine name that was assigned to the given field. | |
FieldsPluginOptions:: |
public | function | Retrieves the machine name of the region set to be the default region. | |
FieldsPluginOptions:: |
public | function | ||
FieldsPluginOptions:: |
public | function | Retrieves the machine name of the selected layout. | |
FieldsPluginOptions:: |
public | function | Retrieves the definition of the selected layout. | |
FieldsPluginOptions:: |
public | function | ||
FieldsPluginOptions:: |
public | function | ||
FieldsPluginOptions:: |
private | function |